Reputation: 253
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.
E.g.:
2016-11-03 00:00:00
--> November 2016
..WHERE MONTHNAME(MONTH(S.date)) AND YEAR(S.date) = '$date'..
This outputs month/year format as "November 2016".
if(isset($_POST['monthPicker'])){$date = $_POST['monthPicker'];}
Database column name for datetime is "S.date"
Upvotes: 2
Views: 3406
Reputation: 883
your Mysql-Query is false. Try this:
..WHERE MONTHNAME(MONTH(S.date)) = '$date->MONTHNAME' AND YEAR(S.date) = '$date->Year'..
Upvotes: 2
Reputation: 133370
You could use concat
"select .....
...
where concat(MONTHNAME(S.date), ' ' , YEAR(S.date)) = '$date';"
Upvotes: 1