标签:
MYSQL查询通过date类型的字段查询一段时间记录
2010-04-29 16:22:34| 分类: 默认分类 |举报|字号 订阅 下载LOFTER客户端
select * from wap_content where week(created_at) = week(now)
如果你要严格要求是某一年的,那可以这样
查询一天:
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 INTERVAL 1 MONTH) <= date(column_time);
查询某几天:
关键字between 等同于 datetime >= 2010-02-02 00:00:00‘ and datetime <= ‘2010-02-15 00:00:00‘;
select * from table where datetime between ‘2010-02-02 00:00:00‘ and ‘2010-02-15 00:00:00‘;
阅读(3733)| 评论(0)
标签:
原文地址:http://www.cnblogs.com/ycliud201410/p/4482066.html