开发者

Oracle timestamp difference greater than X hours/days/months

开发者 https://www.devze.com 2023-03-18 15:17 出处:网络
I am trying to write a query to run on Oracle database. The table ActionTable contains actionStartTime and actionEndTime columns. I need to find out which action took longer than 1 hour to complete.

I am trying to write a query to run on Oracle database. The table ActionTable contains actionStartTime and actionEndTime columns. I need to find out which action took longer than 1 hour to complete.

actionStartTime and actionEndTime are of timestamp type

I have a query which gives me the time taken for each ac开发者_如何学运维tion:

select (actionEndTime - actionStartTime) actionDuration from ActionTable

What would be my where clause that would return only actions that took longer than 1 hour to finish?


Subtracting two timestamps returns an interval. So you'd want something like

SELECT (actionEndTime - actionStartTime) actionDuration
  FROM ActionTable
 WHERE actionEndTime - actionStartTime > interval '1' hour
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号