I have this table:
id, title, views, date (timestamp)
I'm trying to select the most viewd posts from a specific period of time (a week from two months ago, for example)
This is my query right now but it doesn't seem to be working:
SELECT * FROM table
WHERE date > DATE_SUB( DATE_ADD(NOW(), INTERVAL -2 MONTH), INTERVAL 1 WEEK)
ORDER by views DESC
LIMIT 10
Here's a similar question how to select a period of time in mysql?
but I don't want to especify the period with a fixed date, i want it to be relative to the excution of the script.
Any ideas?