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: Need to calc time between to dates in hours and minutes

Re: Need to calc time between to dates in hours and minutes

From: fred <sfsdfsdf_at_fdssd.com>
Date: 19 Jul 1999 09:24:05 -0500
Message-ID: <NxGk3.19441$vw1.758488@newscene.newscene.com>


In article <19990716232641.20172.00001661_at_ng-da1.aol.com>, djordan532_at_aol.com (DJordan532) wrote:
>I need to calculate the difference between two dates and represent them in a
>query in hours and minutes. Additionally, I need to aggregate them into a
>column to use in calculating averages. Will be used in a PL/SQL package. I
>have used this below in my query and it works but it is not accurate:
>
>start_dt = 16-JUL-99 15:10:00
>end_dt = 16-JUL-99 15:41:00
>
>select to_char((end_dt-start_dt)*(24*60),'990.99') elapsed from tablex;
>
>returned valued is 30.90
>
>The value I would like to see is 0:31 for 0 hours and 31 minutes.
>
>I will appreciate all help.
>
>

try this

select to_char(date1, HH24:MI:SS') date_diff,  22/24+40/1440 +trunc(date1) - date1 Fract_value, trunc ( 22/24+40/1440 + trunc(date1) - date1)*24) hours, trunc (mod( (22/24+40/1440 + trunc(date1) - date1) * 1440,60)) mins,

         mod( (22/24+40/1440 + trunc(date1) - date1) * 86400,60) secs, from table1 Received on Mon Jul 19 1999 - 09:24:05 CDT

Original text of this message

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