Skip to content Skip to sidebar Skip to footer

Select Records Where Date == Now + 21 Days (NOT Between)

I have a table session_dates with some fields and a timestamp field named timestart. What I would like to do is select all the records from my table where the field timestart (TIME

Solution 1:

I think you want:

SELECT timestart, timefinish, sessionid 
FROM sessions_dates 
WHERE timestart >= UNIX_TIMESTAMP(DATE_ADD(NOW(), INTERVAL 21 DAY)) AND
      tmestamp < UNIX_TIMESTAMP(DATE_ADD(NOW(), INTERVAL 22 DAY))

Presumably, timestart has a time component. This version takes that into account and still would allow the use of an index on timestart.


Post a Comment for "Select Records Where Date == Now + 21 Days (NOT Between)"