Oracle时间戳差异大于X小时/天/月 [英] Oracle timestamp difference greater than X hours/days/months
问题描述
我正在尝试编写一个在Oracle数据库上运行的查询.表ActionTable包含actionStartTime和actionEndTime列.我需要找出完成超过1小时的操作.
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和actionEndTime是时间戳类型
actionStartTime and actionEndTime are of timestamp type
我有一个查询,该查询为我提供了执行每个操作所需的时间:
I have a query which gives me the time taken for each action:
select (actionEndTime - actionStartTime) actionDuration from ActionTable
我的where
子句是什么,该子句仅返回完成时间超过1小时的操作?
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
这篇关于Oracle时间戳差异大于X小时/天/月的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!