(编辑:jimmy 日期: 2024/12/24 浏览:2)
处理时间时用到了,记录一下。
时间差天数
select '2017-12-10'::date - '2017-12-01'::date;
时间差秒数
select extract(epoch FROM (now() - (now()-interval '1 day') )); select trunc(extract(epoch FROM (now() - (now()-interval '1 day') ))::numeric); select trunc(extract(epoch FROM (now() - (now()-interval '1 day') ))::numeric,1); select round(extract(epoch FROM (now() - (now()-interval '1 day') ))::numeric); select round(extract(epoch FROM (now() - (now()-interval '1 day') ))::numeric,1);
补充:postgresql计算2个日期之间工作日天数的方法
select date_part( 'day', minus_weekend(begin_date,end_date)) from table1 where name in ('a', 'b', 'c')
以上这篇postgresql 计算时间差的秒数、天数实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。