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 ;
上月的數(shù)據(jù)記錄
where DATE_FORMAT(visittime,'%Y%m')=DATE_FORMAT(CURDATE()-interval 1 month,'%Y%m')