mysql date_sub用法

Posted 波神

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql date_sub用法相关的知识,希望对你有一定的参考价值。

查询一天:
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用法的主要内容,如果未能解决你的问题,请参考以下文章