oracle中两个时间戳相减得到间隔毫秒数

原文地址为: oracle中两个时间戳相减得到间隔毫秒数

      主要思想:将时间戳转化为字符串,截取出前边的年、月、日、时、分、秒部分转化为date类型相减,这样可以得到两个时间相差的天数,然后转化为毫秒num1;截取毫秒数部分转化为数字相减,得到num2,然后num1+num2即为两个时间戳的相差毫秒数。

      select (to_date(substr(lEndTime, 1, 19),'yyyy-mm-dd hh24:mi:ss') - to_date(substr(lBeginTime, 1, 19),'yyyy-mm-dd hh24:mi:ss')) * 24 * 3600 * 1000 + to_number(substr(lEndTime, 21, 3)) - to_number(substr(lBeginTime, 21, 3))
  from dual


转载请注明本文地址: oracle中两个时间戳相减得到间隔毫秒数

猜你喜欢

转载自blog.csdn.net/zhengxiuchen86/article/details/80940329