I am trying to write a SELECT query on MySQL to retieve records posted in the last 7 days. My date field is a "datetime" field.
Can anyone shed any light on how I should do this?
Any help greatly appreciated!
Thanks
Jonathan
http://www.mysql.com/doc/en/Date_and_time_functions.html
$query = "SELECT * FROM tablename WHERE fieldname > DATE_SUB(NOW(),INTERVAL 7 DAY)";
fieldname would be the name of your datetime field.