tags:

views:

20

answers:

1

Hi..,

I have read the topic Mysql query: retrieve current date query ., but my question is how can i select the row in a particular given time span.

i.e if my date field is having the entry as 2010:10:27 10:30:00 then that row should be selected when the current time reaches 2010:10:27 10:00 and until the current time reaches the 2010:10:27 18:30:00 . like that. Any help on this would do a great benefits for me..

thanks in advance

+1  A: 

Have you checked out the BETWEEN operator? I think it will be helpful to you. Maybe something like this:

WHERE
  field
  BETWEEN
    DATE_SUB(NOW(), INTERVAL 8 HOURS)
  AND
    DATE_ADD(NOW(), INTERVAL 30 MINUTES)
Emil Vikström