方式一、EXTRACT 方式计算
·原文连接 : https://www.cnblogs.com/xqzt/p/4477239.html
SELECT EXTRACT (DAY FROM dt2 - dt1) DAY, EXTRACT (HOUR FROM dt2 - dt1) HOUR, EXTRACT (MINUTE FROM dt2 - dt1) MINUTE, EXTRACT (SECOND FROM dt2 - dt1) SECOND FROM ( SELECT TO_TIMESTAMP ('2020-02-04 15:07:00','yyyy-mm-dd hh24:mi:ss') dt1, TO_TIMESTAMP ('2020-09-23 16:50:46','yyyy-mm-dd hh24:mi:ss') dt2 FROM dual )
方式二、TO_DATE 方式计算
·原文连接 :https://blog.csdn.net/jsut_rick/article/details/100730000
SELECT CEIL ( ( TO_DATE ( TO_CHAR ( dt2, 'yyyy-mm-dd hh24:mi:ss' ), 'yyyy-mm-dd hh24:mi:ss') - TO_DATE ( TO_CHAR (dt1, 'yyyy-mm-dd hh24:mi:ss' ), 'yyyy-mm-dd hh24:mi:ss') ) * 24 * 60 ) m FROM ( SELECT TO_TIMESTAMP ('2020-02-04 15:07:00','yyyy-mm-dd hh24:mi:ss') dt1, TO_TIMESTAMP ('2020-09-23 16:50:46','yyyy-mm-dd hh24:mi:ss') dt2 FROM dual )