Re: sql to find one year in datetime MySQL column

From: Date: Wed, 16 Jul 2003 17:40:27 +0000
Subject: Re: sql to find one year in datetime MySQL column
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-29283@lists.php.net to get a copy of this message
select * from mytable where year(tstamp) = 2003 Bill wrote:
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


« previous php.db (#29283) next »