Forum Moderators: open

Message Too Old, No Replies

finding all records between 2 dates

         

bleak26

12:56 pm on Mar 3, 2006 (gmt 0)

10+ Year Member



hi, is it possible to create a mysql query to find all the records between 2 dates?

Once again thanks for all the help.

txbakers

1:25 pm on Mar 3, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



mySQL uses dates in the YYYY-MM-DD format so you can use the BETWEEN scalar function to search for records between two dates:

Select * from table where rdate BETWEEN '2006-01-01' and '2006-03-01'

will return a list of rdates between Jan 1 and march 1.

You can also bring back lists of formatted dates in mySQL and can perform DATE_ADD, and DATE_DIFF math in you query.

that way you can bring a list of entries with 60 days of a certain date, or a rolling 7 days for example.