Subject Re: Time Elapsed inside Stored Procedure?
Author Adam
--- In firebird-support@yahoogroups.com, "dr_bentonquest"
<bentonquest@m...> wrote:
>
> Hi there,
>
> I have this four variables: date1 and date2 are DATE, time1 and
time2
> 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
begin
vdate2 = :vdate2 + 1;
end

-- get difference

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


Adam