
Signature
Joseph Meehan
Dia 's Muire duit
On Mar 28, 1:10 am, "Joseph Meehan" <sligoNoSPAM...@hotmail.com>
wrote:
> > As the law requires that £0.005 or less is disregarded, we only look
> > at the third
[quoted text clipped - 11 lines]
> > ive been using the round function but it rounds up at 5 and down at 4
> > but i need it to round up at 6 and down at 5.
>From your sample data I assume you are using the CURRENCY data type
and that negative values are not an issue.
The basic formula for rounding +0.005 down (towards zero) is: multiply
by one hundred, add zero-point-four, truncate, then divide by one
hundred. However, if you divide a value of type CURRENCY by an integer
the result is coerced to DOUBLE. To preserve type, multiply by
CCUR(0.01) e.g. in SQL:
SELECT
CCUR(67.5558) AS NICC_1, INT((NICC_1 * 100) + CCUR(0.4)) * CCUR(0.01)
AS result_1,
CCUR(67.5568) AS NICC_2, INT((NICC_2 * 100) + CCUR(0.4)) * CCUR(0.01)
AS result_2
Jamie.
--