Selecting data based on date

A

Anonymous

Guest
Hi

I would just store dates as a timestamp, it much more resource friendly formating the output in the SELECT part of the query than converting a date in the WHERE part of the query!


if it is a date time field you can do this!

Code:
WHERE date_time >= '2003-07-12 17:00' AND date_time <  '2003-07-15 06:00'

You can also use date_sub() with interval to get a range of date starting at NOW() or a date passed to the quey!

Code:
 WHERE date_time >= date_sub(now(), interval 5 day)

jbr
 
Back
Top