Subject Re: [firebird-support] Timestamp operations in stored procedure
Author Martijn Tonies
Hello Marek,

> Does somebody know how to substract one timestamp from the other in a
> stored procedure?

Simply do "onetimestamp - othertimestamp"... but ...

> We have variables:
> TIME_DIFF timestamp;
> TIME_START timestamp;
> TIME_STOP timestamp;
>
> and I would like to evaluate TIME_DIFF:
>
> TIME_START - not null value;
> TIME_STOP = 'now';
> TIME_DIFF = TIME_STOP-TIME_START;
>
> but such operation results an error:
>
> Error Message:
> ----------------------------------------
> Overflow occurred during data type conversion.
> conversion error from string "0.072731481".
>
> I know, that I'm suggested by Borland's TDateTime operations. I fact I
> thought TDateTime and TIMESTAMP types are very similar in physical
> structure.

TIMESTAMP by itself has nothing to do with TDateTime.

Anyway, "time_diff" is NOT a timestamp, but a "duration".

For example, what "timestamp" (= full date and time) would you give to
23:02 - 18:02 (5 hours). There IS no valid date or time for that, it's just
a period of time, namely "5 hours".

Obviously, the same goes for "27-06-2005 18:20" - "22-06-2005 13:20" -
A period of 5 days and 5 hours. Now, "5 days and 5 hours" will never be
a valid date/time, will it?

With regards,

Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, Oracle & MS SQL
Server
Upscene Productions
http://www.upscene.com