Re: Subtracting dates, any help is welcome

From: Karel Sprenger <ks_at_ic.uva.nl>
Date: 15 Jul 1998 16:52:06 +0200
Message-ID: <uaf6b88vd.fsf_at_ic.uva.nl>


Hi,

"J. van der Laan" <jan_at_nl.uu.net> writes:
>
> Surely this is pretty simple....but how simple it is I do not know.
>
> I want to subtract two dates from eachother and want the output to be in
> hours/minutes/seconds.
>
> The only thing I did achieve until now is;
> SQL statement;
> # select sum(out_time-in_time) from database where field=value;
>
> Output;
> SUM(OUT_TIME-IN_TIME)
> ---------------------
> .053784722
>
> What does this output value say/mean???
> btw; The OUT_TIME and IN_TIME fields are of type DATE.
>

Oracle returns the difference between two DATE variables or fields in days. The fractional part constitutes the hours, minutes and seconds. So, SUM(OUT_TIME-IN_TIME)*24 would be the difference in hours (with the fractional part constitutin the minutes and seconds).

Hope this helps.

-- 
Karel Sprenger <ks_at_ic.uva.nl>               | phone: +31-20-525 2302
Informatiseringscentrum                     |        +31-20-525 2741
Universiteit van Amsterdam                  | fax  : +31-20-525 2084
Turfdraagsterpad 9, NL-1012 XT  AMSTERDAM   | home : +31-20-670 0942
*** PGP Public Key available on servers *** | email: <cjas_at_xs4all.nl>
Received on Wed Jul 15 1998 - 16:52:06 CEST

Original text of this message