数据仓库服务 GAUSSDB(DWS)-时间/日期函数:timestampadd(field, numeric, timestamp)

时间:2023-11-10 17:34:07

timestampadd(field, numeric, timestamp)

描述:将以单位field的整数时间间隔(秒数可以带小数)添加到日期时间表达式中。若数值为负,则表示从给定的时间日期时间表达式中减去对应的时间间隔。field支持的参数为year,month,quarter,day,week,hour,minute,second和microsecond。

返回值类型:timestamp

示例:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
SELECT timestampadd(year, 1, TIMESTAMP '2020-2-29');
    timestampadd
---------------------
 2021-02-28 00:00:00
(1 row)

SELECT timestampadd(second, 2.354156, TIMESTAMP '2020-11-13');
        timestampadd
----------------------------
 2020-11-13 00:00:02.354156
(1 row)
support.huaweicloud.com/sqlreference-dws/dws_06_0309.html