Subject | Re: format the float value |
---|---|
Author | legrand_legrand_63 |
Post date | 2007-01-02T22:26:12Z |
>Cast is the first solution (but it fires an exception in case of
> Hello guys,
>
> how do i format the float value to a string like ##.##?
>
> something like CAST(MyValue As VARCHAR(5))?
truncation).
You can also try the Oracle syntax available at
http://perso.orange.fr/Udf4ORA/ with the to_charn(num,fmt) UDF
function wher format can be composed with:
- 0 zero leading format
- 9 blank leading format
- . or D decimal separator
- , or G thousand separator
- FM trailing minus position
- this function rounds decimals, and send ##### in case of integer
part overflow
Examples:
to_charn(-123.4,'999.999') --> '-123.400'
to_charn(123.4,'999.999') --> ' 123.400'
to_charn(1234,567,'999,000.999') --> ' 1,234.567'
to_charn(123.4,'000000.999') --> ' 000123.400'
to_charn(123.4,'FM000.999') --> '123.400'
to_charn(123.6,'999') --> ' 124'
to_charn(123.6,'99') --> '######'
Regards
PAscal