-- 查询今天的数据
select * from `res_basic` where to_days(created_time) = to_days(CURDATE());
-- 查询昨天的数据
select * from `res_basic` where to_days(CURDATE()) - to_days(created_time)<=1;
-- 查询最近7天的数据
select * from `res_basic` where created_time > DATE_SUB(CURDATE(),INTERVAL 7 DAY);
-- 查询最近一个季度的数据
select * from `res_basic` where created_time > DATE_SUB(CURDATE(), INTERVAL 3 MONTH)
-- 本季度的数据
select * from `res_basic` where quarter(created_time) = quarter(CURDATE());
-- 上季度的数据
select * from `res_basic` where quarter(created_time) = quarter(DATE_SUB(CURDATE(), INTERVAL 1 QUARTER));
-- 查询制定时间段内的数据
select * from `res_basic` where created_time between '2021-9-1' and '2021-10-3';
-- -- 最近一年的数据
select * from `res_basic` where created_time > DATE_SUB(CURDATE(), INTERVAL 1 YEAR);