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>);
GROUP BY YEAR(i.push_date), MONTH(i.push_date)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.