mysql query in php date format

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
karthiksg
Forum Newbie
Posts: 2
Joined: Tue May 12, 2009 8:07 pm

mysql query in php date format

Post 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.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: mysql query in php date format

Post by Celauran »

You could easily use BETWEEN.
mikosiko
Forum Regular
Posts: 757
Joined: Wed Jan 13, 2010 7:22 pm

Re: mysql query in php date format

Post 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
Post Reply