时间:2021-07-01 10:21:17 帮助过:5人阅读
向日期添加指定的时间间隔。
DATE_ADD(date,INTERVAL expr type)
其中:
date : 合法的日期表达式
expr : 需要添加的时间间隔
type : 时间间隔的单位,允许值如下:
MICROSECOND
SECOND
MINUTE
HOUR
DAY
WEEK
MONTH
QUARTER
YEAR
SECOND_MICROSECOND
MINUTE_MICROSECOND
MINUTE_SECOND
HOUR_MICROSECOND
HOUR_SECOND
HOUR_MINUTE
DAY_MICROSECOND
DAY_SECOND
DAY_MINUTE
DAY_HOUR
YEAR_MONTH
将当前时间添加2天后输出:
SQL : SELECT now() AS NOW, DATE_ADD(now(), INTERVAL 2 DAY) AS TOW_DAYS_LATER;
结果:
+---------------------+---------------------+
| NOW | TOW_DAYS_LATER |
+---------------------+---------------------+
| 2020-05-17 23:41:25 | 2020-05-19 23:41:25 |
+---------------------+---------------------+
1 row in set (0.00 sec)
参考
MySQL DATE_ADD函数
标签:art 输出 int 间隔 cond add set second mysq