[英]Postgresql how to query a time duration?
在我的表格案例中,有 2 個 tiemstamp 字段如下所示:
check_in check_out
"2021-09-07 07:25:00" "2021-09-08 17:10:00"
"2020-09-25 06:02:00" "2020-09-27 15:20:00"
"2020-10-26 05:42:00" "2020-10-29 13:05:00"
如何查詢 check_out - check_in 大於 2 天的行,例如:
select * from case where check_out - check_in > 2 days ;
然后輸出將是:
check_in check_out
"2020-09-25 06:02:00" "2020-09-27 15:20:00"
"2020-10-26 05:42:00" "2020-10-29 13:05:00"
你很接近。 您需要提供正確的間隔值
select *
from case
where check_out - check_in > interval '2 days';
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.