Forum Moderators: open

Message Too Old, No Replies

mysql date interval

         

CodilX

10:39 am on Sep 24, 2009 (gmt 0)

10+ Year Member



hi there,

can someone help me with this problem..

i'm trying to extract entries from my db, with an interval of FROM 14days ago to 7days ago.. i can't get anything to work.. please help ;)

mark_roach

3:20 pm on Sep 24, 2009 (gmt 0)

10+ Year Member



Try something like:

select ID, my_date_col from my_table where DATEDIFF(now(),my_date_col) > 7 and DATEDIFF(now(),my_date_col) < 14

rocknbil

4:26 pm on Sep 24, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You can use now() for datetime types, curdate() for date only types (although both will probably work)

A second choice:

date_sub (curdate(), interval 7 day)
date_sub (curdate(), interval 14 day)

CodilX

7:11 am on Sep 29, 2009 (gmt 0)

10+ Year Member



i keep getting errors .. help?..

rocknbil

7:17 pm on Sep 29, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



We could point you to the mySQL documentation . . . . or just ask to see the full select statement. :-)