mysql 统计
每周:
select count(*) as cnt,week(editdate) as weekflg from projects where year(editdate)=2007 group by weekflg
每月:
select count(*) as cnt,month(editdate) as monthflg from projects where year(editdate)=2007 group by monthflg
每天:
select count(*) as cnt from projects group by date(editdate)
Demo:
(thinkphp框架)
M('UserCourseSection')
->field('count(*) as nums,left(last_time, 10) as time')
->group('date(last_time)')
->order('last_time desc')
->select();
last_time 为数据库日期字段