前提这个table有一个时间字段insert_time
select count(*),DATE_FORMAT(a.insert_time,'%e') as e from table a
where DATE_FORMAT(a.insert_time,'%m')='08'
group by e
date 参数是合法的日期。format 规定日期/时间的输出格式。
可以使用的格式有:
select count(*),DATE_FORMAT(a.insert_time,'%e') as e from
where DATE_FORMAT(a.insert_time,'%m')='08'
group by e
MySQL DATE_FORMAT() 函数
MySQL Date 函数定义和用法
DATE_FORMAT() 函数用于以不同的格式显示日期/时间数据。语法
DATE_FORMAT(date,format)date 参数是合法的日期。format 规定日期/时间的输出格式。
可以使用的格式有:
| 格式 | 描述 |
|---|---|
| %a | 缩写星期名 |
| %b | 缩写月名 |
| %c | 月,数值 |
| %D | 带有英文前缀的月中的天 |
| %d | 月的天,数值(00-31) |
| %e | 月的天,数值(0-31) |
| %f | 微秒 |
| %H | 小时 (00-23) |
| %h | 小时 (01-12) |
| %I | 小时 (01-12) |
| %i | 分钟,数值(00-59) |
