Re: Date Difference

From: Tommy Wareing <p0070621_at_brookes.ac.uk>
Date: 20 Jan 1995 12:09:31 GMT
Message-ID: <3fo95r$82q_at_cs3.brookes.ac.uk>


In article <3feaqs$d47_at_portal.gmu.edu>, agandhi_at_osf1.gmu.edu (Ajay M Gandhi) says:
>Ajay M Gandhi (agandhi_at_osf1.gmu.edu) wrote:
>: Vince Cross (bartok_at_bnr.ca) wrote:
>: : Ajay M Gandhi <agandhi_at_mason1.gmu.edu> wrote:
>: : >Is there any function that can find the number of hours and
>: : >minutes between two date functions?
>: : >For example, I am interested in getting 02:30 with the follwoing
>: : >data.
>: : >Start date = 12-Jan-1995
>: : >End Date = 12-Jan-1995.
>: : >Both the above dates were updated into the database at an
>: : >interval of 2 hrs and 30 mins.
>: -- What happens if the start hour is 23:00 and end hour is 01:00 (during
>: midnight). The difference will be 1 - 23 = -22 and which I don't want. The
>: same concepts will be true for minutes and seconds.
>: -- If I want to find the duration between two dates which are six months apart
>: then again the above solution is not going to work. Am I right ?

My turn!

TRUNC(end-start) days,
TO_DATE(end-start+TRUNC(SYSDATE), 'HH24:MI') hours

(if you really want the number of seconds difference, then use (end-start)*24*60*60 instead of that *REALLY* horrible expression)

_________________________   __________________________________________
/  Tommy Wareing          \ /  I've been looking for an original sin,  \
|  p0070621_at_brookes.ac.uk  X   One with a twist and a bit of a spin    |
\  0865-483389            / \     -- Pandora's Box, Jim Steinman       /
 ~~~~~~~~~~~~~~~~~~~~~~~~~   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Received on Fri Jan 20 1995 - 13:09:31 CET

Original text of this message