[PostgreSql] time conversion

PostgreSql timestamp conversion time

to_timestamp(first_time / 1000) AT TIME ZONE 'PRC'

insert image description here

Sao operation

There is a long and a timestamp in the table, and I want to subtract the data with minutes > 5 minutes. I can’t find any useful ones on the Internet, so I write one myself.

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

It can be run, delete /60 is to ask for seconds
insert image description here

Guess you like

Origin blog.csdn.net/daohangtaiqian/article/details/130091984