mysql中时间计算函数SQL DATE_SUB()用法
时间:2021-07-01 10:21:17
帮助过:16人阅读
select DATE_SUB(CURDATE(), INTERVAL
1 YEAR)
as yearTime
--
一天前
select DATE_SUB(CURDATE(), INTERVAL
1 DAY)
as selecttime
--
一月前
select DATE_SUB(CURDATE(), INTERVAL
1 MONTH)
as selecttime
--
三年前
select DATE_SUB(CURDATE(), INTERVAL
3 YEAR)
as yearTime
- SELECT DATE_SUB(‘2010-08-12‘, INTERVAL 3 DAY) AS NewDate
结果: 2010-08-09
2.SELECT DATE_SUB(‘2010-08-12‘, INTERVAL ‘3-2‘ YEAR_MONTH) AS NewDate
结果: 2007-06-12
3.SELECT DATE_SUB(‘2011-09-14 2:44:36‘, INTERVAL ‘2:26‘ HOUR_MINUTE) AS NewDate
结果: 2011-09-14 00:18:36
mysql中时间计算函数SQL DATE_SUB()用法
标签:class date_sub post log 今天 day color blog interval