I am using following query to show Gross and Net Amount Month & Year-wise:
SELECT DATE_FORMAT(BILLDATE,'MMM-yyyy'), SUM(GROSSAMOUNT), SUM(NETAMOUNT)
FROM BILLDETAILS GROUP BY MONTH(BILLDATE);
Other columns are displayed correctly except the first one that involves Date_Format. It is displaying MMM-yyyy in all rows instead of the actual Month and Year.
Because
'MMM-yyyy'is not a correct date format. You probably want'%b-%Y'http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-format