RE: subtract dates

  • From: "Scott Canaan" <srcdco@xxxxxxx>
  • To: <oracle-l@xxxxxxxxxxxxx>
  • Date: Wed, 12 May 2004 11:27:26 -0400

I use this code to convert the difference between to dates into date
format:

decode(trunc((a.event_time - b.event_time) * 24),0,
                to_char(trunc((a.event_time - b.event_time) * 1440)),
                to_char(trunc((a.event_time - b.event_time) * 24)) ||
':' ||
                to_char(trunc((a.event_time - b.event_time) * 1440) -
                        trunc((a.event_time - b.event_time) * 24) *
60,'FM00'))
|| ':' ||
                to_char(round(((a.event_time - b.event_time) * 1440 -
                        trunc((a.event_time - b.event_time) * 1440)) *
60),'FM00
')

It displays the time in the format of hours:minutes:seconds.

Scott Canaan (srcdco@xxxxxxx)
(585) 475-7886
"Life is like a sewer, what you get out of it depends on what you put
into it." - Tom Lehrer.


-----Original Message-----
From: oracle-l-bounce@xxxxxxxxxxxxx
[mailto:oracle-l-bounce@xxxxxxxxxxxxx] On Behalf Of Huascar Espinoza
Sent: Wednesday, May 12, 2004 11:16 AM
To: oracle-l@xxxxxxxxxxxxx
Subject: subtract dates

Hi guys: =3D20
 =3D20
How can I subtract two dates ('DD/MM/YY HH:MI:SS') to obtain the result
=3D
in hours? MONTHS_BETWEEN don't obtain a precise value. =3D20
 =3D20
Thank you,

Hu=3DE1scar
----------------------------------------------------------------
Please see the official ORACLE-L FAQ: http://www.orafaq.com
----------------------------------------------------------------
To unsubscribe send email to:  oracle-l-request@xxxxxxxxxxxxx
put 'unsubscribe' in the subject line.
--
Archives are at //www.freelists.org/archives/oracle-l/
FAQ is at //www.freelists.org/help/fom-serve/cache/1.html
-----------------------------------------------------------------
----------------------------------------------------------------
Please see the official ORACLE-L FAQ: http://www.orafaq.com
----------------------------------------------------------------
To unsubscribe send email to:  oracle-l-request@xxxxxxxxxxxxx
put 'unsubscribe' in the subject line.
--
Archives are at //www.freelists.org/archives/oracle-l/
FAQ is at //www.freelists.org/help/fom-serve/cache/1.html
-----------------------------------------------------------------

Other related posts: