qxandxt

导航

MySql 按日期条件查询数据

复制代码
本周内:
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();


查询7天:
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);


查询一年:
select * from table  where DATE_SUB(CURDATE(), INTERVAL 1 YEAR) <= date(column_time);
复制代码

 

posted on   qxandxt  阅读(6525)  评论(0编辑  收藏  举报

努力加载评论中...
点击右上角即可分享
微信分享提示