Page 1 of 1

mysql query in php date format

Posted: Wed Dec 31, 2014 12:07 pm
by karthiksg
hi all happy new year to all.
i am having a date field with (Y-m-d) format say (2014-12-31)
need to know how i can mysql query (Y-m) say (2014-12) meaning all rows in table should display for the whole month

any help will be much appreciated.

Re: mysql query in php date format

Posted: Wed Dec 31, 2014 12:13 pm
by Celauran
You could easily use BETWEEN.

Re: mysql query in php date format

Posted: Wed Dec 31, 2014 12:32 pm
by mikosiko
You can use one of the mysql date functions as date_format() or extract()

http://dev.mysql.com/doc/refman/5.1/en/ ... ate-format
http://dev.mysql.com/doc/refman/5.1/en/ ... on_extract