> The dates are stored in a MySql db.
> 
> I checked out the MySql DATE_FORMAT function -- pretty cool.
> 
> However, pardon my ignorance here, how can I do date comparisons?
> 
> For example, if I want to retrieve records from the db where the date
is
> between say, 2003-02-01 and 2003-02-07, will MySql be able to compare
the
> strings?
> 
> I stored my dates as integer fields to do such a comparison, but it
looks
> like I need to graduate to MySql date time functions..........

If you've done it correctly and stored your dates in a MySQL DATE,
DATETIME, or TIMESTAMP column, then you can do something like this:

SELECT * FROM table WHERE yourdate BETWEEN 20030201 AND 20030207

If you're storing them in an INT column, then change it over to one of
the above. 

Go back to the manual and read about date_sub() and date_add() in MySQL
for further date manipulation...

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to