且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Oracle 日期减法

更新时间:2022-03-08 08:40:03

那个小数点是提供的两个日期之间相差的天数.您可以做一些数学运算,将其转换为天、小时、分钟、秒等.

That decimal is the number of days difference between the two dates provided. You can do a little math to convert that to days, hours, minutes, seconds, etc.

编辑:我知道你在找什么.我确定有更简单的方法,但我可能会这样完成:

EDIT: I see what you're looking for. I'm sure there's an easier way, but I would probably accomplish it thusly:

select trunc(5.3574585) days, 
       trunc(mod((5.3574585) * 24, 24)) hours, 
       trunc(mod((5.3574585) * 24 * 60, 60)) minutes, 
       trunc(mod((5.3574585) * 24 * 60 * 60, 60)) seconds 
  from dual;

...其中 5.3574585 是减法返回的天数...

...where 5.3574585 is the number of days returned by the subtraction...

注意:这并没有经过真正的测试,这是我的想法.