I have an SQL timestamp field and I need to group it by month like
Jan, Feb, Mar, ... but in numbers (01, 02, 03, ...)
I've tried
GROUP BY DATE_FORMAT(i.push_date, '%Y-%m')
But it's not working.
I have an SQL timestamp field and I need to group it by month like
Jan, Feb, Mar, ... but in numbers (01, 02, 03, ...)
I've tried
GROUP BY DATE_FORMAT(i.push_date, '%Y-%m')
But it's not working.
Try to use the Month() method.
Select Month(<field>) from <table> group by Month(<column>);
what you get back will be the month in number form. You might to group by month and year which would be:
Select Year(<column), Month(<field>) from <table> group by Month(<column>), Year(<column>);