Results 1 to 3 of 3

Thread: Mysql Date + 60

  1. #1

    Thread Starter
    Addicted Member TheGoldenShogun's Avatar
    Join Date
    Mar 2001
    Location
    VA/MD... anywhere around the beltway
    Posts
    236

    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.

  2. #2
    scoutt
    Guest
    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?

  3. #3
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923
    You can do something like this for the where clause
    Code:
    SELECT.......WHERE TO_DAYS(NOW()) - TO_DAYS(OrderDate) = 60

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width