select date_part('day', cast(now() as TIMESTAMP)- cast('2022-01-23 23:00:00'::date as TIMESTAMP));
SELECT round(CAST(extract(epoch FROM(to_timestamp('2022-03-09 12:00:00','yyyy-MM-dd HH24:mi:ss') - to_timestamp('2022-03-08 00:00:00','yyyy-MM-dd HH24:mi:ss'))) / (24 * 60 * 60) AS NUMERIC) ,0);
执行SQL:
select to_number( date_trunc('day' ,'2023-09-14 01:35:00'::TIMESTAMP - '2023-09-10 01:35:00'::TIMESTAMP + INTERVAL '1 day')::text ,'9999999999999') as s1;
执行结果: