Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: format difference of dates as date
"Tobias Wagner" <none_at_rz.uni-karlsruhe.de> wrote in message
news:d2u15e$etg$1_at_news2.rz.uni-karlsruhe.de...
> Rauf Sarwar wrote:
> > You would have to do this in a PLSQL function that takes end_date and
> > start_date and returns varchar2 as 'DD HH24:MI:SS'.
> >
> > Hint: (end_date - start_date) * 86400 will give you date difference in
> > seconds. 86400 are number of seconds in a 24 hour period. Now you can
> > do the math.
>
> Isn't there a way to cast a number to a date and then use the regular
> to_char function?
> Can't I add the difference of start- and endtime to some kind of "zero"
> date?
>
> Cheers,
> Tobi
>
>
Dates are dates and the difference between two dates is a number. Formats
are string representations of a number. You can express a date as a Julian
number, but when you subtract them you have a number. You could convert
that to a date and get some date in 4000 BC. What you want is NOT a date
but an interval. The difference between two dates is an interval of time.
I can think of several ways to do that, but Rauf is correct. You could be
fancy about it an create an object type (like a C struct) with years,
months, days, hours, minutes, seconds and populate that.
Jim
Received on Tue Apr 05 2005 - 10:00:51 CDT
![]() |
![]() |