Page 1 of 1

Monthly Select

Posted: Tue Mar 14, 2006 4:34 pm
by Technocrat
I have DB entries with a mysql date using now(). I need to select the ones that have happened this month using PHP. I am unsure of how to get the range. Does strtotime have a start month, and end month or something I can use to do this?

Posted: Tue Mar 14, 2006 5:02 pm
by feyd

Code: Select all

SELECT * FROM `table` WHERE MONTH(`field`) = '3'

Posted: Tue Mar 14, 2006 5:19 pm
by Technocrat
Did not work, but then I checked the input and its using php time() as the data, not now(). :oops:

Posted: Tue Mar 14, 2006 5:26 pm
by feyd

Code: Select all

SELECT * FROM `table` WHERE MONTH(FROM_UNIXTIME(`field`)) = '3'
:?:

Posted: Tue Mar 14, 2006 5:30 pm
by Technocrat
Perfect, thank you!