数据仓库服务 GAUSSDB(DWS)-时间/日期函数:timestampdiff(field, timestamp1, timestamp2)

时间:2024-10-21 16:50:41

timestampdiff(field, timestamp1, timestamp2)

描述:将两个日期参数相减(timestamp2 - timestamp1),并以单位field作为返回值。若相减值为负,则函数返回值为负。field支持的参数为year、month、quarter、day、week、hour、minute、second和microsecond。

返回值类型:bigint

示例:

1
2
3
4
5
SELECT timestampdiff(day, timestamp '2001-02-01', timestamp '2003-05-01 12:05:55');
 timestampdiff 
---------------
      819
(1 row)
support.huaweicloud.com/sqlreference-830-dws/dws_06_0309.html