MySQL
MySQL日付集計

MySQL日毎、周毎、月毎集計

More than 3 years have passed since last update.

1.日毎
  group by date(created)

2.周毎
 ・日曜日開始
  group by date(created + interval 1 - DAYOFWEEK(created) day)
 ・月曜日開始
  group by date(created - interval (5 + DAYOFWEEK(created))%7 day)

3.月毎
  group by date(created + interval 1 - DAYOFMONTH(created) day)
  或いは
  group by date_format(created, '%Y-%m')

※createdのデータ型はDATETIME