Subject Re: Time Elapsed inside Stored Procedure?
Author Adam
--- In, "dr_bentonquest"
<bentonquest@m...> wrote:
> Hi there,
> I have this four variables: date1 and date2 are DATE, time1 and
> are VARCHAR(5) and contain a time value, which I know is always
> between '00:00' and '24:59'.
> I am looking for ideas on how to compute the time elapsed (in hours)
> between the two sets of variables.
> Thanks for any hints,
> -Benton

I can't remember the syntax precisely, I did something similar a
while back, but converting the other way.

-- convert these time strings to timestamps.
-- I chose an arbitrary date

vdate1 = Cast(('1/1/2005' || Date1) as TIMESTAMP);
vdate2 = Cast(('1/1/2005' || Date2) as TIMESTAMP);

-- Make sure you handle span if it crosses over midnight

if (:vdate2 < :vdate1) then
vdate2 = :vdate2 + 1;

-- get difference

hrs = (:vdate2 - :vdate1) * 24;