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

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

posted @ 2015-07-31 01:44  mellowsmile  阅读(12813)  评论(0编辑  收藏  举报