现在的位置: 首页 > 综合 > 正文

根据时间字段,查询某一时间以前的数据

2013年09月20日 ⁄ 综合 ⁄ 共 270字 ⁄ 字号 评论关闭

查询一天:

select * from table where to_days(column_time) = to_days(now());
select * from table where date(column_time) = curdate();

查询一周:

select * from table where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(column_time);

查询一个月:

select * from table where DATE_SUB(CURDATE(), INTERVAL 1 MONTH) <= date(column_time);

抱歉!评论已关闭.