Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Subtract Hours From A Given Date

Re: Subtract Hours From A Given Date

From: Connor McDonald <connor_mcdonald_at_yahoo.com>
Date: Fri, 10 Sep 1999 17:59:45 +0800
Message-ID: <37D8D691.6E22@yahoo.com>


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...
--



Connor McDonald
"These views mine, no-one elses etc etc" connor_mcdonald_at_yahoo.com

"Some days you're the pigeon, and some days you're the statue." Received on Fri Sep 10 1999 - 04:59:45 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US