如何在MySQL中减去时间

时间:2020-12-04 16:30:21

How can I subtract time in MySQL? For example, today is 16 March; I want to subtract 15 days to reach 1 March. Are there any methods that can be used to subtract 15 days from the current date?

如何在MySQL中减去时间?例如,今天是3月16日;我想减去15天到3月1日。有没有什么方法可以用来减去当前日期的15天?

1 个解决方案

#1


37  

SELECT DATE(NOW()-INTERVAL 15 DAY)

For a list of units see http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-add

有关单位列表,请参阅http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-add

#1


37  

SELECT DATE(NOW()-INTERVAL 15 DAY)

For a list of units see http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-add

有关单位列表,请参阅http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-add