MYSQL获取最近一段时间的SQL写法
最近一周 (create_time 为数据库字段)
select count(*) from out_car_manage where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(create_time);
最近一个月
select count(*) from out_car_manage where DATE_SUB(CURDATE(),INTERVAL 1 MONTH) <= date(create_time);
最近三个月
select count(*) from out_car_manage where DATE_SUB(CURDATE(),INTERVAL 3 MONTH) <= date(create_time);
当天
SELECT * from out_car_manage where status =0 and date(create_time) = curdate() ORDER BY create_time desc