-
Mysql Date + 60
I need to find all the orders that took place 60 days ago. I had
SELECT ID, name, orderdate FROM events WHERE orderdate = current_date - 60;
but its not giving me anything. Then I tried this...
SELECT ID, name, orderdate FROM events WHERE orderdate > current_date - 60;
but that is giving me all the fields in my database (it goes back to June 2001). Maybe I am misunderstanding how this current_date - x function works.
-
you will have to use mktime so get the correct day and the correct month for that day. what is your date forma t you are using?
-
You can do something like this for the where clause
Code:
SELECT.......WHERE TO_DAYS(NOW()) - TO_DAYS(OrderDate) = 60