Click to See Complete Forum and Search --> : Time difference function ?


bang_dba
10-01-2003, 10:53 AM
Hi,
Is there any in built function which will give me The diffence between two specified times ?
For example i want difference between
(Mon Sep 1 00:00:05 2003) and (Mon Sep 1 05:45:04 2003)

jmodic
10-01-2003, 11:36 AM
Yes, there is. Although it is technicaly implemented as a function, it is ususally not considered a true function, but rather an operator. It is called "MINUS" (has nothing in common with MINUS "SET OPERATOR")or "SUBTRACTION" in spoken language, it's simbol is "-". It is used both in NUMBER as well as in DATE arythmetics.

To get the time difference between two dates, simply use it like this:

SELECT :date2 - :date1 FROM dual;

You'll get time difference, expressed in days.

tamilselvan
10-01-2003, 05:39 PM
I frequently use to find the process run time by executing the following query:
select prcsinstance seq,
prcstype, prcsname,
begindttm, enddttm,
runstatus sta,
trunc((enddttm - begindttm)*24) HH,
(trunc((enddttm - begindttm)*24*60) - (trunc((enddttm - begindttm)*24)*60)) MM,
(trunc((enddttm - begindttm)*24*60*60) - (trunc((enddttm - begindttm)*24*60))*60) SS
from tablex;

This may also help you.

Tamil