|
Home > Archive > SQL Anywhere Feedback > January 2006 > TRUNCNUM with dropping 'the rest'
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
TRUNCNUM with dropping 'the rest'
|
|
| Pavel Karady 2006-01-18, 7:23 am |
| Greetings templars,
I wasn't lucky to find ANY function in ASA 7 through 9 which truncates a
number and actually 'drops' the truncated values. The current work of
TRUNCATE (and TRUNCNUM) looks like:
SELECT TRUNCNUM( 655.3487462, 2 );
produces 655.3400000, I'd like it to have produced 655.34; I'm forced to use
this *fancy* expression (@value DOUBLE):
SET @value = 655.3487462;
SELECT SUBSTR(CAST(@value AS LONG VARCHAR), 1, LOCATE(CAST(@value AS LONG
VARCHAR),'.')+2);
which finds the '.' (point) and takes everything from the beginning up to
that point + number of decimals :))
If I might be incorrect in something or there *is* such a function (or
easily replaceable), please correct me. Thanks a lot!
Pavel
| |
| Dmitri 2006-01-18, 7:23 am |
| Pavel Karady пишет:
> I wasn't lucky to find ANY function in ASA 7 through 9 which truncates a
> number and actually 'drops' the truncated values. The current work of
> TRUNCATE (and TRUNCNUM) looks like:
>
> SELECT TRUNCNUM( 655.3487462, 2 );
>
> produces 655.3400000, I'd like it to have produced 655.34
I'd say it is a formatting issue which I prefer to leave to the
frontend. However isn't the
SELECT convert(numeric(18,2
), TRUNCNUM( 655.3487462, 2));
what you're after?
Dmitri.
| |
| Pavel Karady 2006-01-18, 7:23 am |
| "Dmitri" <NOdimSPAM@mail15.com> wrote in message
news:43ce36f2$1@foru
ms-2-dub...
> SELECT convert(numeric(18,2
), TRUNCNUM( 655.3487462, 2));
Yes, that's it; and as I can see, omitting the TRUNCNUM rounds the result,
so it has to stay there. I'll leave adding the TRUNCATEANDCUTTHETHR
OAT
function on the rest of the audience..
Thank you very much
Pavel
|
|
|
|
|