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: Problem printing difference in date

Re: Problem printing difference in date

From: J.P. <jp_boileau_at_yahoo.com>
Date: 22 May 2002 06:37:57 -0700
Message-ID: <7e388bc3.0205220537.2c05c8b1@posting.google.com>


This works good, too:

SQL> select

  2     to_char(trunc((sysdate+.5 - sysdate) * 24)) || ':' || 
  3     ltrim(to_char(((sysdate+.5 - sysdate) * 24) -
trunc(((sysdate+.5 -
  4     sysdate) * 24)), '09'))
  5  from
  6     dual;

TO_CHAR(TRUNC((SYSDATE+.5-SYSDATE)*24))||':'



12:00

This assumes that sysdate is the older date, and that sysdate + .5 is the newer date.

JP

Forte Agent <1443131_at_usenetplanet.com> wrote in message news:<0rfieukc26uep9pe4jfv0bso085ndauevr_at_4ax.com>...
> This is gotta be simple but I do not know how. . . I am simply tring
> to calculate difference in time and print it, as shown below:
>
>
> SQL> alter session set nls_date_format='MM/DD/YYYY HH24:MI:SS';
>
> Session altered.
>
> SQL> select to_date('5/2/2002 10:00:00') - to_date('5/1/2002 1:00:00')
> from dual;
>
> TO_DATE('5/2/200210:00:00')-TO_DATE('5/1/20021:00:00')
> ------------------------------------------------------
> 1.375
>
> SQL>
>
>
>
> Instead of "1.375", I would like to get "33:00" (thirty three hours of
> difference) as output (or "0/1/0000 9:00" = One day and nine hours).
> How to do it? I know I can do something like this:
>
>
>
> SQL> select trunc(sysdate) + 1.375 from dual;
>
> TRUNC(SYSDATE)+1.37
> -------------------
> 05/21/2002 09:00:00
>
>
>
> But again, I just want "33:00" as output, not with some bogus date
> along with it. Thank you in advance.
Received on Wed May 22 2002 - 08:37:57 CDT

Original text of this message

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