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: Subtracting Dates

Re: Subtracting Dates

From: Alan Mills <Alan.Mills_at_xservices.pants.fujitsu.com>
Date: Thu, 31 Jul 2003 10:07:11 +0100
Message-ID: <bgamaq$1hbb$1@news.icl.se>

"Ed prochak" <ed.prochak_at_magicinterface.com> wrote in message news:4b5394b2.0307301246.2504f1d8_at_posting.google.com...
> Mark.Powell_at_eds.com (Mark D Powell) wrote in message
news:<2687bb95.0307281823.506f85f6_at_posting.google.com>...
> > carlos_lotero <member33668_at_dbforums.com> wrote in message
news:<3158472.1059425551_at_dbforums.com>...
> > > Hello,
> > >
> > > I need to show the difference between dates in format: hh24:mi:ss.
> > >
> > > Thanks,
> > >
> > > Carlos
> >
> > Carlos, it is fairly simple. Subtract the older date value from the
> > newer one. The result is days and fractions there of. Divide the
> > base (or days) by 24 to get hours. Multiple the fraction by the
> > number of minutes in a day to get minutes and parts there of.
> > Multiple the fraction of a minute by 60 to get seconds.
> >
> > I am not at work so I do not have a computer available to provide a
> > partial example, but if you need one after you play around with the
> > above and no one else posts anything I will post one.
> >
> > HTH -- Mark D Powell --
>
> Nice little misdirection there Mark. That should make any student
> programmers scratch their heads. I love it! Regular programmers will
> see it and say "oh, yeah he meant..."
>
> Ed Prochak

Yeah, a bit procedural. IF the difference is less than a day then use something like

SELECT TO_CHAR(TRUNC(SYSDATE) + (date1value - date2value), 'HH24:MI:SS') FROM DUAL hee hee, had to correct my typing there. Put MM instead of MI for the minutes first time around. Haven't done that for a while! Can remember phoning Oracle support the first time I did it, about twelve years ago, wondering why my minutes weren't ticking over. lol Received on Thu Jul 31 2003 - 04:07:11 CDT

Original text of this message

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