postgresql 計算時間差的秒數(shù)、天數(shù)實例
處理時間時用到了,記錄一下。
時間差天數(shù)
select '2017-12-10'::date - '2017-12-01'::date;
時間差秒數(shù)
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個日期之間工作日天數(shù)的方法
select date_part( 'day', minus_weekend(begin_date,end_date)) from table1 where name in ('a', 'b', 'c')
以上這篇postgresql 計算時間差的秒數(shù)、天數(shù)實例就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關文章
快速解決PostgreSQL中的Permission denied問題
這篇文章主要介紹了快速解決PostgreSQL中的Permission denied問題,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2021-01-01使用Postgresql 實現(xiàn)快速插入測試數(shù)據(jù)
這篇文章主要介紹了使用Postgresql 實現(xiàn)快速插入測試數(shù)據(jù),具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2021-01-01使用postgresql 模擬批量數(shù)據(jù)插入的案例
這篇文章主要介紹了使用postgresql 模擬批量數(shù)據(jù)插入的案例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2021-01-01