select * from t_user where time > DATE_SUB(CURDATE(), INTERVAL 1 WEEK) --最近一周 select * from t_user where time > DATE_SUB(CURDATE(), INTERVAL 3 MONTH) --最近三月 select * from t_user where time > DATE_SUB(CURDATE(), INTERVAL 1 YEAR) --最近一年
select * from t_user where time <= DATE_SUB(CURDATE(), INTERVAL 1 WEEK) --一周前 select * from t_user where time <= DATE_SUB(CURDATE(), INTERVAL 3 MONTH) --三月前 select * from t_user where time <= DATE_SUB(CURDATE(), INTERVAL 1 YEAR) --一年前