postgresql 计算时间差的秒数、天数

时间差天数

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);
 

 

上一篇:DataNode的工作机制


下一篇:1523. Count Odd Numbers in an Interval Range