sql to find one year in datetime MySQL column
| From: | bill | Date: | Wed, 16 Jul 2003 17:24:52 +0000 |
| Subject: | sql to find one year in datetime MySQL column | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-29282@lists.php.net to get a copy of this message | ||
How can I find all the records for a single year from a db that has a datetime
column (in MySQL)?
This seems to work:
SELECT * from mytable
WHERE tstamp < '2003-01-01 00:00:00'
AND tstamp > '2002-01-01 00:00:00'
But this doesn't:
SELECT * from mytable
WHERE tstamp LIKE '2002%'
Is there a simpler way than the first one?
kind regards,
bill hollett