Oracle计算两个时间戳相差秒数,精确到毫秒

时间:2024-03-12 07:36:42

with t as

(select to_timestamp(\'2015-01-01 11:13:15.023456\',

\'yyyy-mm-dd hh24:mi:ss.ff9\') t1,

to_timestamp(\'2015-01-01 12:13:15.123556\',

\'yyyy-mm-dd hh24:mi:ss.ff9\') t2

from dual)

select abs((trunc(t1 - 0, \'mi\') - trunc((t2 - 0), \'mi\')) * 24 * 60 * 60 +

extract(second from t1 - t2))

from t

输出结果: 3600.1001