下面的代码给出了以毫秒为单位的差异:
with t as (select systimestamp - to_timestamp(sysdate ) diff from dual)
select extract(day from diff) * 24 * 3600000+
extract(hour from diff) * 3600000+
extract(minute from diff) * 60000 +
extract(second from diff) * 1000
dif
from t要将毫秒转换为小时,分钟,秒,请根据需要修改和使用以下查询:
with t as (select systimestamp - to_timestamp(sysdate ) diff from dual)
select extract(day from diff) * 24 * 3600000+
extract(hour from diff) * 3600000+
extract(minute from diff) * 60000 +
extract(second from diff) * 1000
dif,
(to_char (to_date(round(( extract(day from diff) * 24 * 3600000+
extract(hour from diff) * 3600000+
extract(minute from diff) * 60000 +
extract(second from diff) * 1000)/1000), 'SSSSS' ), 'HH24"Hrs" MI"Min" SS"Sec"')) timeval
from t