You can use this in your MySQL WHERE clause to return records created in the last 7 days / week:
created >= DATE_SUB(CURDATE(),INTERVAL 7 day)
Also use NOW () in subtraction to get hh: mm: ss resolution. Thus, to return records created exactly (to the second) in the last 24 hours, you can do:
created >= DATE_SUB(NOW(),INTERVAL 1 day)
Akshay Apr 16 '14 at 5:37 a.m. 2014-04-16 05:37
source share