mysql 查询一天,一周等隔日数据

--查询一天
select * from tbl_order where date(tbor_create_time) = curdate();
select * from tbl_order where to_days(tbor_create_time) = to_days(now());
--查询一个周
select * from tbl_order where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(tbor_create_time);
--查询一个月
select * from tbl_order where DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(tbor_create_time);
--两个日期之间的数据
select * from tbl_order where tbor_create_time>'2012-01-20 00:00:00' and tbor_create_time<'2012-02-7 00:00:00';

你可能感兴趣的:(mysql)