Subject TIME calculation errors
Author sugi
Dear all,

I found out the hard way tonight that the following stored procedure
code doesn't work... Firebird 1.5.2, Win32, Dialect 3 database.

declare variable begin_time time;
declare variable end_time time;
declare variable delta time;
//calculate delta after fetching begin_time and end_time
delta = end_time - begin_time;

The calculation seem to fail everytime with the following error message:
"Overflow occured during data type conversion. Conversion error from
string "3000.0000"."

After some fiddling, it seems that the result of the (end_time -
begin_time) expression is processed as a numeric data. Changing the
delta variable into an integer solves the issue, partially...

declare variable delta integer;
delta = end_time - begin_time;

But now the delta variable holds an INTEGER containing elapsed time in
SECONDS, while I need this to be a TIME or TIMESTAMP format... Manually
casting it back to TIME data fails with the same error message as above.
Am i missing something here?

The funny thing is that I recall writing some similar code in the past,
but i don't remember having *any* problems like this.

Thanks in advance,