Re: Retrieve the month from a date field
| From: | Adam Royle | Date: | Wed, 09 Apr 2003 11:49:18 +0000 |
| Subject: | Re: Retrieve the month from a date field | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-26950@lists.php.net to get a copy of this message | ||
Hi Shaun,
SELECT * FROM tblYourTableName WHERE month(yourDateColumnName) = 4
Be careful, as this will select all years (you may not want this). If you only want a certain month in a certain year, try this:
SELECT * FROM tblYourTableName WHERE month(yourDateColumnName) = 4 AND year(yourDateColumnName) = 2003
Adam
Hi, I have a date field in my table (YYYY-MM-DD). Is it possible to retrieve all the rows that occur in a given month i.e. April? Thanks for your help