Selecting Dates
| From: | Jordan Elver | Date: | Sun, 08 Apr 2001 11:00:11 +0000 |
| Subject: | Selecting Dates | ||
| Groups: | php.db php.general | ||
| Request: | Send a blank email to php-db+get-8355@lists.php.net to get a copy of this message | ||
Hi,
I'm trying to select records based on dates.
I have a table with dates in the format 2001-04-08 and I'm using the query:
SELECT name, description, date_time FROM events WHERE YEAR(date_time) = 2001
AND MONTH(date_time) = 04 AND DAYOFMONTH(date_time) = 08
But it doesn't yield any records? I don't really understand why? It seems to
be the last bit 'DAYOFMONTH(date_time) = 08' which cause a problem because if
I leave it out of the query, it selects all records for a particular month in
a particular year as expected.
Cheers,
Jord