On May 24, 6:58 am, Akhenaten <jonko...@gmail.com> wrote:
> I need more coffee.....
>
> I have a 'DATE' column [NOW()] so my records are timestamped. Can't
> quite figure out the correct query for pulling records between now and
> a given period of time (24 hours, ten minutes, whatever...) What am I
> missing for that last bit?
>
> SELECT * FROM `my_table` WHERE `my_date` BETWEEN NOW() AND ???
>
> TIA.
> ./JLK
One of the ways to achieve this is to use the DATE_SUB function.
http://dev.mysql.com/doc/refman/5.0/...ction_date-sub
Nb.
select * from `my_table` where `my_date` > DATE_SUB(NOW(), INTERVAL 1
DAY)
and `my_date` <
DATE_SUB(NOW(), INTERVAL 1 HOUR) ;
Regards,
Bill