Oracle时间戳差异大于X小时/天/月 [英] Oracle timestamp difference greater than X hours/days/months

查看:179
本文介绍了Oracle时间戳差异大于X小时/天/月的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆