Oracle计算时间差

时间差=终止时间-开始时间

1.字符串型(要转化成数字类型)

天:ROUND(TO_NUMBER(TO_DATE(A.EST_DATE,'YYYYMMDDHH24MISS')-TO_DATE(A.INS_DATE,'YYYYMMDDHH24MISS')))

小时:ROUND(TO_NUMBER(TO_DATE(A.EST_DATE,'YYYYMMDDHH24MISS')-TO_DATE(A.INS_DATE,'YYYYMMDDHH24MISS'))*24)

分钟:ROUND(TO_NUMBER(TO_DATE(A.EST_DATE,'YYYYMMDDHH24MISS')-TO_DATE(A.INS_DATE,'YYYYMMDDHH24MISS'))*24*60)

秒:ROUND(TO_NUMBER(TO_DATE(A.EST_DATE,'YYYYMMDDHH24MISS')-TO_DATE(A.INS_DATE,'YYYYMMDDHH24MISS'))*24*60*60)

毫秒:ROUND(TO_NUMBER(TO_DATE(A.EST_DATE,'YYYYMMDDHH24MISS')-TO_DATE(A.INS_DATE,'YYYYMMDDHH24MISS'))*24*60*60*60)

2.数字型

天:ROUND(TO_NUMBER(END_DATE - START_DATE))

小时:ROUND(TO_NUMBER(END_DATE - START_DATE) * 24)
分钟:ROUND(TO_NUMBER(END_DATE - START_DATE) * 24 * 60)
秒:ROUND(TO_NUMBER(END_DATE - START_DATE) * 24 * 60 * 60)
毫秒:ROUND(TO_NUMBER(END_DATE - START_DATE) * 24 * 60 * 60 * 60)

 

你可能感兴趣的:(Oracle数据库,Oracle计算时间差)