MySQL select only where Timestamp is from last 10 days

Viewed 30568

I want to limit my query to results that have been entered in the last 10 days. The TIMESTAMP column is called Date. How do I do it?

$result = mysql_query("SELECT * FROM Posts WHERE (City = '$city2') ORDER by Comments DESC LIMIT 5");

Thanks

4 Answers

Assuming your data is hourly can also use:

(SELECT * FROM comments ORDER BY DateTime desc LIMIT 240) order by DateTime

I found this to be more exact in returning exactly 10 days to the hour.

Related