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: Sybrand Bakker <postbus_at_sybrandb.demon.nl>
Date: Mon, 20 May 2002 21:05:53 +0200
Message-ID: <u4iieu0do1gkueguo9nq10ph8gg4s46ere@4ax.com>


On Mon, 20 May 2002 14:44:44 -0400, Forte Agent <1443131_at_usenetplanet.com> wrote:

>
>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.
>
>
>

select 24 * (to_date('5/2/2002 10:00:00') - to_date('5/1/2002 1:00:00')) -- as the unit of date variable is a day and a day has 24 hours
from dual;

What did you drink before posting this question?

Hth

Sybrand Bakker, Senior Oracle DBA

To reply remove -verwijderdit from my e-mail address Received on Mon May 20 2002 - 14:05:53 CDT

Original text of this message

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