Oracle-获得两个DateTime列之间的分钟差的最佳SELECT语句? [英] Oracle - Best SELECT statement for getting the difference in minutes between two DateTime columns?

查看:119
本文介绍了Oracle-获得两个DateTime列之间的分钟差的最佳SELECT语句?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试满足来自客户端的相当困难的报告请求,并且我需要花几分钟的时间去弄清两个DateTime列之间的差异.我尝试使用trunc并使用各种格式"进行舍入,似乎无法使用结合起来才有意义.有没有一种优雅的方法可以做到这一点?如果没有,有没有任何方法可以做到这一点?

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?

推荐答案

SELECT date1 - date2
  FROM some_table

返回天数差异.乘以24可得出小时数差异,而乘以24 * 60则可获得分钟数.所以

returns a difference in days. Multiply by 24 to get a difference in hours and 24*60 to get minutes. So

SELECT (date1 - date2) * 24 * 60 difference_in_minutes
  FROM some_table

应该是您要找的

这篇关于Oracle-获得两个DateTime列之间的分钟差的最佳SELECT语句?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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