I have a field date_confirmed which is a datetime.
So an example of the contents would be
2011-01-03 20:54:41
The where clause I built to extract recent rows from this table based on the date_confirmed is as follows…
WHERE DATEDIFF(g.date_confirmed, CURDATE()) <= 28
I am using PHP with MySQL and I want to only extract rows where the date in date_confirmed is less than 28 days.
Can someone help me / points me in a better direction?
Thanks.
Well, you don’t say what’s not working, but I think you might have meant to switch the parameters around:
as you had it,
CURDATE()would (I assume) always be more recent thang.date_confirmednd thereforeDATEDIFF()would alwys return a negative number – and therefore always be<= 28