Subject | Re: [firebird-support] Maths problem 1.0(Dialect 1) -> 1.5(Dialect 3) |
---|---|
Author | Helen Borrie |
Post date | 2003-09-01T15:06:33Z |
At 03:30 PM 1/09/2003 +0100, you wrote:
casting to integer until you've done the multiplication on the DOUBLE
PRECISION.
Try
CAST (CURRENT_DATE - OLD.LAST) * 1440) AS INTEGER
btw, If you need "nearest minute" rather than "last whole minute", don't
cast the double, but pass it to a ROUND(..) udf.
--h
>OK what am I doing wrong?The integer casting will truncate the result, not round it, so don't do the
>
>(('NOW' - OLD.LAST) * 1440)
>
>Is working fine in FB1.0 on a Dialect 1 database
>(LAST is a TIMESTAMP, and the value goes into a SMALLINT)
>
>CAST((CAST('NOW' AS TIMESTAMP) - OLD.LAST) AS INTEGER)* 1440
>
>Will actually compile on FB1.5RC4 on a Dialect 3 database,
>but it is not putting 'minutes' into the SMALLINT - I always
>get 0.
>
>This equation is used in several 'INSERT' triggers and all
>give the same problem.
casting to integer until you've done the multiplication on the DOUBLE
PRECISION.
Try
CAST (CURRENT_DATE - OLD.LAST) * 1440) AS INTEGER
btw, If you need "nearest minute" rather than "last whole minute", don't
cast the double, but pass it to a ROUND(..) udf.
--h