摘要: PG 中時間想減後爲interval ,比較兩個時間大於某個小時或者分鐘等可以直接通過interval來實現
example1:
-- 判斷兩個時間差大於4個小時
select timestamp '2013-11-11 10:00:00' - timestamp '2013-11-08 12:00:00' > interval '4 hour';
example2:
-- 獲取時間差的總體小時差 然後再判斷
mrapp=> select extract(day from t) * 24 + extract(hour from t) > 4 from (select (timestamp '2013-12-14 12:00:00' - timestamp '2013-12-11 4:00:00') as t) as a;
其他的都比較麻煩了 暫不列