------时间差:ROUND(TO_NUMBER(END_DATE - START_DATE)),t=TO_NUMBER(END_DATE - START_DATE)
------ROUND(t,精确位数),day
------ROUND(t*24,精确位数),hour
------ROUND(t*24*60,精确位数),minutes
------时间差(day)------
select
round(
to_number(
TO_DATE('2018-02-20 17:45:04','yyyy-mm-dd hh24:mi:ss')-TO_DATE('2018-02-19 08:34:04','yyyy-mm-dd hh24:mi:ss')
),2
) as Day
from dual;
------时间差(hour)------
select
round(
to_number(
TO_DATE('2018-02-20 17:45:04','yyyy-mm-dd hh24:mi:ss')-TO_DATE('2018-02-19 08:34:04','yyyy-mm-dd hh24:mi:ss')
)*24,2
) as Hour
from dual;
-------------时间差转换时分秒格式------------
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('2011-02-04 15:07:00','yyyy-mm-dd hh24:mi:ss') dt1
,to_timestamp('2011-05-17 19:08:46','yyyy-mm-dd hh24:mi:ss') dt2
from dual);
Oracle时间差
最新推荐文章于 2024-06-14 09:38:45 发布