PostgreSql 时间戳 转换 时间
to_timestamp(first_time / 1000) AT TIME ZONE 'PRC'
骚操作
表里有一个long 有一个 timestamp 两个时间,我要相减求分钟数>5分钟的数据,网上找的都是坑,没有好用的,自己写一个。
select (extract(EPOCH from (create_time-(to_timestamp(first_time / 1000) AT TIME ZONE 'PRC')) / 60))::INTEGER
,create_time,first_time
from t_event_export where event_id='36db3c07-72fe-4a99-80b3-ca630d4e1bb2' and first_time > '1677600000000' and first_time <= '1680278399000'
and
(extract(EPOCH from (create_time-(to_timestamp(first_time / 1000) AT TIME ZONE 'PRC')) / 60))::INTEGER > 5
可以运行的,把/60 删除就是求秒