小编典典

如何从mysql中的当前日期时间中减去30天?

mysql

如何从mysql中的当前日期时间减去30天?

SELECT * FROM table
WHERE exec_datetime BETWEEN DATEDIFF(NOW() - 30 days) AND NOW();

阅读 2239

收藏
2020-05-17

共1个答案

小编典典

SELECT * FROM table
WHERE exec_datetime BETWEEN DATE_SUB(NOW(), INTERVAL 30 DAY) AND NOW();

http://dev.mysql.com/doc/refman/5.5/zh-CN/date-and-time-
functions.html#function_date-add

2020-05-17