首页 > 数据库技术 > 详细

mysql date_sub用法

时间:2018-05-19 15:20:54      阅读:206      评论:0      收藏:0      [点我收藏+]
查询一天:
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);
查询指定天数
select * from table where DATE_SUB(CURDATE(), INTERVAL 2 DAY) <= date(column_time);

 

mysql date_sub用法

原文:https://www.cnblogs.com/boshen-hzb/p/9060289.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!