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

Home -> Community -> Usenet -> c.d.o.server -> Re: Difference between dates in seconds (9i)

Re: Difference between dates in seconds (9i)

From: nobody <nobody_at_nowhere.com>
Date: Fri, 07 Nov 2003 20:28:59 GMT
Message-ID: <fgTqb.2489$XDB.325@news01.bloor.is.net.cable.rogers.com>


select (date1-date2)*24*60*60 from dual;

"Michael Gill" <mydba_at_usa.com> wrote in message news:fb510dcd.0311071147.78e732cc_at_posting.google.com...
> 9i introduces the interval datatype and this is now the type returned
> from a date subtraction. The following code will display the
> difference between the dates:
>
> declare
> duration interval day(6) to second(6);
> v_start timestamp := to_timestamp('5-NOV-2003 14:00:00.000000',
> 'DD-MON-YYYY HH24:MI:SSxFF');
> v_end timestamp(6) := sysTimestamp;
> begin
> duration := v_end - v_start;
> dbms_output.put_line ('Now: '||to_char(v_end,'DD-MON-YYYY
> HH24:MI:SSxFF'));
> dbms_output.put_line ('Difference: '|| to_char(duration));
> end;
>
> BUT, the result is:
> Now: 06-NOV-2003 12:24:22.244127000
> Difference: +000000 22:24:22.244127
>
> PL/SQL procedure successfully completed.
>
> I don't want to display the value! I need to extract the hours,minutes
> and seconds to save the number of seconds.
>
> Any ideas???
>
>
>
> Michael Gill
> Sr. Database Administrator
> mydba_at_usa.com
Received on Fri Nov 07 2003 - 14:28:59 CST

Original text of this message

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