Subject Re: [firebird-support] ERROR? in Time Stamps
Author Helen Borrie
At 01:36 PM 26/04/2005 +0100, you wrote:


> > In a stored procedure I need to be able to compare 2 time stamp values (
> > ie TS1 and TS2)
> >
> > I need to be able to test if (TS1 - 3 minutes) is less than TS2
>
>WI-V1.5.1.4481 Firebird 1.5
>
>It's an error or what wrong in my mind?
>
>select current_timestamp,
> (current_timestamp - 1) as Minus1day, /* OK */
> (current_timestamp - 1.0/2) as Minus12hour, /* OK */
> (current_timestamp - 1.0/3) as Minus8hour, /* Err */
> (current_timestamp - 1.0/4) as Minus6hour, /* Err */
> (current_timestamp - 1.0/6) as Minus4hour, /* Err */
> (current_timestamp - 1.0/12) as Minus2hour, /* Err */
> (current_timestamp - 1.0/24) as Minus1hour /* Err */
> from rdb$database

Not enough scale!

select current_timestamp,
(current_timestamp - 1) as Minus1day, /* OK */
(current_timestamp - 1.0/2) as Minus12hour, /* OK */
(current_timestamp - 1.000/3) as Minus8hour,
(current_timestamp - 1.00/4) as Minus6hour,
(current_timestamp - 1.000/6) as Minus4hour,
(current_timestamp - 1.000/12) as Minus2hour,
(current_timestamp - 1.000/24) as Minus1hour
from rdb$database

3 places isn't really accurate for 6, 12 and 24 - so cut your cloth to suit
your coat.

./hb