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

Home -> Community -> Mailing Lists -> Oracle-L -> Re: Date / Time

Re: Date / Time

From: <Witold.Iwaniec_at_atl.bluecross.ca>
Date: Tue, 10 Jul 2001 10:41:27 -0700
Message-ID: <F001.00345E80.20010710094119@fatcity.com>

Hi

The script below may help you - it will display different components in separate columns, modify it with your two dates and proper table name and remove what you don't need

select sysdate,

       sysdate - to_date('03072001000000', 'DDMMYYYYHH24MISS') diffr,
        trunc(sysdate - to_date('03072001000000', 'DDMMYYYYHH24MISS')) days,
        trunc(mod(sysdate - to_date('03072001000000', 'DDMMYYYYHH24MISS'), 1) *
24) hrs,
        trunc(mod(mod(sysdate - to_date('03072001000000', 'DDMMYYYYHH24MISS'),
1) * 24, 1) * 60) min,
        round(mod(mod(mod(sysdate - to_date('03072001000000',
'DDMMYYYYHH24MISS'), 1) * 24, 1) * 60, 1) * 60) sec,
        to_char(trunc(sysdate - to_date('03072001000000', 'DDMMYYYYHH24MISS')))
|| ' ' ||
        lpad(trunc(mod(sysdate - to_date('03072001000000', 'DDMMYYYYHH24MISS'),
1) * 24), 2, '0') || ':' ||
        lpad(trunc(mod(mod(sysdate - to_date('03072001000000',
'DDMMYYYYHH24MISS'), 1) * 24, 1) * 60), 2, '0') || ':' ||
        lpad(round(mod(mod(mod(sysdate - to_date('03072001000000',
'DDMMYYYYHH24MISS'), 1) * 24, 1) * 60, 1) * 60), 2, '0')     Difference
 from dual

HTH Witold

Sajid Iqbal wrote:

> Hello All
>
> I want to display the "time elapsed" between two dates - in days, hours,
> minutes and seconds.
>
> If I do "select date1 - date2", the result is : 12.0194907
>
> Is there a function that will turn the number of days into something more
> legible? Ideally i'd like to do ;
>
> "to_char(12.0194907,'DD:HH:MI:SS')" but obviously that won't work. Is
> there a solution other than writing a complex function myself which will
> have to * by 24, / by 60 and substr etc to get the different bits of the
> number?
>
> Please CC any replies directly to me at siqbal_at_vianetworks.co.uk
>
> Thanks in advance,
> Saj.
>
> --
> Sajid Iqbal
> Database Team Leader
>
> --

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: 
  INET: Witold.Iwaniec_at_atl.bluecross.ca

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Tue Jul 10 2001 - 12:41:27 CDT

Original text of this message

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