Subject Re: [firebird-support] Cast( float as varchar(20) ) formatting?
Author Helen Borrie
At 08:07 AM 9/07/2010, you wrote:
>This seems like something that should be easy

Once you cast a number as characters, they are not numerical any more, just a string of characters.

>OR I should've found easily on the group...but...
>If I:
>CharField = cast( FloatField as varchar(20) )
>I end up with:
>1.2345 = "1.2345000000000000"
>How do I format it so the trailing "0"s are NOT in the return string?

Charfield = cast(FloatField as varchar(n)) where n is the total length you want. Note, for a float type, any digits after the seventh one can be considered meaningless, anyway.

If you mean "how do you get rid of a trail of zeroes in a string", look at the string functions in the Appendix of the v.2.1 release notes. If you are using an older Firebird, look at the string functions available in the various UDF libraries around the houses.

If you are doing this conversion inside PSQL anyway, then manipulate the string in a sub-procedure.