码迷,mamicode.com
首页 > 数据库 > 详细

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

时间:2015-07-31 06:36:39      阅读:227      评论:0      收藏:0      [点我收藏+]

标签:

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

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

标签:

原文地址:http://www.cnblogs.com/mellowsmile/p/4691076.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!