Re: how to get all the records of a particular month....
| From: | Hugh Bothwell | Date: | Mon, 03 Sep 2001 14:18:10 +0000 |
| Subject: | Re: how to get all the records of a particular month.... | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-65747@lists.php.net to get a copy of this message | ||
"Sagar" <sagarphp@yahoo.com> wrote in message
news:001b01c1347e$b58e2580$6dfb7ccb@ravella...
> I hope some one will solve my problem.
> I have a table in which a field is of date type.
> i want a mysql query to get all the records of the table
> into an array of a particular month.
Some clarification is needed: do you want all entries for
a given month of ANY year, or of a specific year?
If the first, I would use
SELECT * FROM table
WHERE MONTH(datefield) = mm
(See the MySQL documentation, section 7.4.11)
Or, for the second
SELECT * FROM table
WHERE datefield BETWEEN
'yyyy-mm-01' AND 'yyyy-mm-31'
... how's that?