Re: Minutes and Seconds

From: rob <rob_at_dsdelft.nl>
Date: Sat, 1 Jun 2002 10:02:35 +0200
Message-ID: <ad9v2s$9ks$1_at_news.tudelft.nl>


 select (to_date('31-MAY-2002 23:59:00','DD-MON-YYYY HH24:MI:SS') -

           to_date('31-MAY-2002 21:59:00','DD-MON-YYYY HH24:MI:SS') )  from dual;
returns the number of days between the dates so

*24 returns the hours
*24*60 the minutes
*24*60*60 the seconds

Use mod fuction to work with the fractions

select trunc(

(to_date('31-MAY-2002 23:00:31','DD-MON-YYYY HH24:MI:SS') -

            to_date('30-MAY-2002 21:59:00','DD-MON-YYYY HH24:MI:SS'))
           ) Days
,      trunc(mod(

(to_date('31-MAY-2002 23:00:31','DD-MON-YYYY HH24:MI:SS') -
to_date('30-MAY-2002 21:59:00','DD-MON-YYYY HH24:MI:SS')) * 24,24) ) Hours , trunc(mod(
(to_date('31-MAY-2002 23:00:31','DD-MON-YYYY HH24:MI:SS') -
to_date('30-MAY-2002 21:59:00','DD-MON-YYYY HH24:MI:SS')) * 24 * 60 ,60) ) Minutes , trunc(mod(
(to_date('31-MAY-2002 23:00:31','DD-MON-YYYY HH24:MI:SS') -
to_date('30-MAY-2002 21:59:00','DD-MON-YYYY HH24:MI:SS')) * 24 * 60 * 60 ,60) ) Seconds

FROM DUAL; Rob Received on Sat Jun 01 2002 - 10:02:35 CEST

Original text of this message