mysql中如何查询最近24小时
where visittime >= NOW() - interval 1 hour;
昨天
where visittime between CURDATE()-interval 1 day and CURDATE();
最近7天
where visittime between CURDATE()-interval 7 day ;
上周
where week(visittime)= week(CURDATE()-interval 7 day )and year(visittime)=year(CURDATE()-interval 7 day )
最近30天
where visittime between CURDATE()-interval 30 day ;
上月的数据记录
where DATE_FORMAT(visittime,'%Y%m')=DATE_FORMAT(CURDATE()-interval 1 month,'%Y%m')