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

idcbe.com

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';


[本日志由 edwin 于 2015-02-08 09:27 PM 编辑]
文章来自: 网络
引用通告: 查看所有引用 | 我要引用此文章
Tags: mysql 语句 查询 一天 一周 数据
评论: 0 | 引用: 0 | 查看次数: 4429
发表评论
昵 称:
密 码: 游客发言不需要密码.
内 容:
验证码: 验证码
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.
字数限制 50 字 | UBB代码 关闭 | [img]标签 关闭
idcbe.com