您可以转换为导致间隔数据类型的 TIMESTAMP
SQL> create table test(a date, b date);
Table created.
SQL> insert into test values (sysdate - 1.029384, sysdate);
1 row created.
SQL> select 1440*(b-a) diff_in_secs from test;
DIFF_IN_SECS
------------
1482.31667
SQL> select (cast(b as timestamp)-cast(a as timestamp)) diff_in_secs from test;
DIFF_IN_SECS
---------------------------------------------------------------------------
+000000001 00:42:19.000000
extract('hour' from your_interval_expression)
您可以使用等提取单个元素。
SQL> select extract(day from diff)||'d '||extract(hour from diff)||'h '||extract(minute from diff)||'m '||extract(second from diff)||'s' from (select (cast(b as timestamp)-cast
(a as timestamp)) diff from test);
EXTRACT(DAYFROMDIFF)||'D'||EX
--------------------------------------------------------------------------------
1d 0h 42m 19s