presto timestmp使用
日期和时间运算符
时区转化
SELECT timestamp '2012-10-31 01:00 UTC'; 2012-10-31 01:00:00.000 UTC SELECT timestamp '2012-10-31 01:00 UTC' AT TIME ZONE 'America/Los_Angeles'; 2012-10-30 18:00:00.000 America/Los_Angeles
时间戳、时间和日期
select '1633939200000', substr('1633939200000',1,10) as a, from_unixtime(cast(substr('1633939200000',1,10) as int)) as b, -- 将13位毫秒级的unix timestamp截取到秒级别 format_datetime(from_unixtime(cast(substr('1633939200000',1,10) as int)),'yyyy-MM-dd')
结果:
1633939200000 | 1633939200 | 2021-10-11 16:00:00.000 | 2021-10-11 |
比较举例
select current_timestamp >TIMESTAMP '2021-10-11 16:00'
结果 :
True