Forum Moderators: open

Message Too Old, No Replies

Date Ranges?

         

Furutsuzeru

11:01 pm on Aug 6, 2008 (gmt 0)

10+ Year Member



I do not know how to explain this exactly, although I'm clueless how to SELECT rows that have been submitted from x date to y date. I have seen this done before, but I find no solutions to this, and the manual brings me no where.

Can anybody give me a hint or a solution to my doubts, please?

LifeinAsia

11:09 pm on Aug 6, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Assuming you have somesort of time/date stamp on your rows, you can do:
SELECT *
FROM TableName
WHERE TimeStamp BETWEEN Date1 AND Date2

Gerwin7

11:12 pm on Aug 6, 2008 (gmt 0)

10+ Year Member



The mysql manual also says:

quote:

For best results when using BETWEEN with date or time values, you should use CAST() to explicitly convert the values to the desired data type. Examples: If you compare a DATETIME to two DATE values, convert the DATE values to DATETIME values. If you use a string constant such as '2001-1-1' in a comparison to a DATE, cast the string to a DATE.

Furutsuzeru

11:17 pm on Aug 6, 2008 (gmt 0)

10+ Year Member



Thanks guys.