Oracle 计算两个日期之间的时间差(天/小时/分钟/秒)

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/u013171471/article/details/78435688

Oracle 计算两个日期之间的时间差:

SELECT ESTIME, EETIME, TD, TH, TM, ROUND((TT-TM)*60) AS TS  
FROM (
SELECT ESTIME, EETIME, TD, TH, TRUNC((TT-TH)*60) AS TM, (TT-TH)*60 AS TT 
FROM (
SELECT ESTIME, EETIME, TD, TRUNC((TT-TD)*24) AS TH, (TT-TD)*24 AS TT  
FROM (
SELECT
     TO_NUMBER(EETIME - ESTIME) AS TT, 
     TRUNC(TO_NUMBER(EETIME - ESTIME)) AS TD,
     ESTIME, EETIME 
 FROM (
      SELECT TO_DATE('2017-11-01 00:20:31','YYYY-MM-DD HH24:MI:SS') AS ESTIME, TO_DATE('2017-11-02 01:15:30','YYYY-MM-DD HH24:MI:SS') AS EETIME FROM DUAL 
 ) 
 )
 )
 );
 

其中:

              ESTIME: 开始时间

              EETIME:结束时间

              TD:相差天数

              TH:相差小时数

              TM:相差分钟数

              TS:相差秒数
展开阅读全文

没有更多推荐了,返回首页