EKBG EKBG - 1 year ago 115
PHP Question

Convert datetime to get month name in mysql

Datetime column data is as

2016-11-03 00:00:00
. I want to get month and year from this and convert month number as month name.


2016-11-03 00:00:00
--> November 2016

Code Snippet

..WHERE MONTHNAME(MONTH(S.mydate)) AND YEAR(S.mydate) = '$date'..

Month year picker code

This outputs month/year format as "November 2016".

if(isset($_POST['monthPicker'])){$date = $_POST['monthPicker'];}

Database column name for datetime is "S.date"

Answer Source

You could use concat

"select ..... 
where concat(MONTHNAME(S.date), ' ' , YEAR(S.date))  = '$date';"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download