date_add() 函数向日期添加指定的时间间隔。
date 参数是合法的日期表达式。expr 参数是您希望添加的时间间隔。
type 参数可以是下列值:
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 |
假设我们有如下的 "orders" 表:
orderid | productname | orderdate |
---|---|---|
1 | jarlsberg cheese | 2008-11-11 13:23:44.657 |
现在,我们想要向 "orderdate" 添加 45 天,这样就可以找到付款日期。
我们使用下面的 select 语句:
结果:
orderid | orderpaydate |
---|---|
1 | 2008-12-26 13:23:44.657 |