Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Subtract Hours From A Given Date
Kenneth C Stahl wrote:
>
> Alex Hudghton wrote:
>
> > Kenneth C Stahl <BlueSax_at_Unforgettable.com> wrote in message
> > news:37D90F79.4BF16C2_at_Unforgettable.com...
> > > Thomas Kyte wrote:
> > >
> > > > or
> > > >
> > > > select (sysdate - 5/24) from dual
> > > >
> > >
> > > I don't trust that method since it depends on irrational numbers.
> > >
> >
> > What's irrational about 5 and 24 ??
> >
> > Alex
>
> I had no idea at all that this concept was not widely understood. I
> learned it in high school.
>
> If you divide one number by another and the result does not have a
> mantissa that has a finite value (or does not have a finite value within
> allowable precision) then it is an irrational number.
>
> In programming languages that use IEEE floats, it is guaranteed that
> there will be rounding errors for irrational numbers. Therefore the
> result of a division that results in an irrational number cannot be
> considered accurate.
True...but dates in oracle only need to respect a precision to 5 decimal places since there are only 86400 seconds in a day...
Thus, (to use a example of "irrational"), you could find 5/11ths of day (which in reality is of infinite decmials 0.45454545....) and you WILL get the right answer...
Using oracle 5/11ths of a day is:
10 hrs, 54 mins, 33secs
Using arbritary precision:
10 hrs, 54 mins, 32.727272727272727272... seconds
No difference...
--
"Some days you're the pigeon, and some days you're the statue." Received on Fri Sep 10 1999 - 04:59:45 CDT
![]() |
![]() |