Oracle - 用于获取两个日期时间列之间的分钟差异的最佳 SELECT 语句?
我正在尝试满足客户的一个相当困难的报告请求,并且我需要在几分钟内找出两个日期时间列之间的差异。 我尝试将 trunc 和 round 与各种 格式 一起使用,但似乎无法实现找到一个有意义的组合。 有没有一种优雅的方法来做到这一点? 如果没有,有没有任何方法可以做到这一点?
I'm attempting to fulfill a rather difficult reporting request from a client, and I need to find away to get the difference between two DateTime columns in minutes. I've attempted to use trunc and round with various formats and can't seem to come up with a combination that makes sense. Is there an elegant way to do this? If not, is there any way to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
返回天数差异。 乘以 24 即可得到小时差值,乘以 24*60 即可得到分钟差值。 所以
应该是你正在寻找的
returns a difference in days. Multiply by 24 to get a difference in hours and 24*60 to get minutes. So
should be what you're looking for
默认情况下,oracle 日期减法返回以天为单位的结果。
因此,只需乘以 24 即可获得小时数,然后再乘以 60 即可获得分钟数。
例子:
By default, oracle date subtraction returns a result in # of days.
So just multiply by 24 to get # of hours, and again by 60 for # of minutes.
Example:
http://asktom.oracle.com/tkyte/Misc/DateDiff.html - 截至 2012 年 1 月 30 日,链接已失效
看起来这是资源:
http://asktom.oracle.com/pls/asktom/ASKTOM.download_file?p_file=6551242712657900129
http://asktom.oracle.com/tkyte/Misc/DateDiff.html - link dead as of 2012-01-30
Looks like this is the resource:
http://asktom.oracle.com/pls/asktom/ASKTOM.download_file?p_file=6551242712657900129
在
where
子句中使用timestampdiff
。例子:
Use
timestampdiff
atwhere
clause.Example: