Gday all,
I have a SQL field Varchar 20 chars long. It almost always contains numeric data, often with leading zeros such as 00001234. How do I get rid of the leading zeros so I just get 1234.
if NumericText({Table.Field})
then
ToText(ToNumber({Table.Field}),0,""
else
{Table.Field}
This checks a field to determine if the value is numeric - if it is it converts to a number - the 0 and "" tells Crystal 0 decimal places, with no thousands separator. In either case the numeric value is converted to text so that you will see the numeric results without leading zeros, and the text results as text - phew!
I liked all suggestions, but tried yours first - mainly because I had done this before but just couldn't remember what I had done. I could only recall it was done with some combination of ToText and ToNumber.
Anyway, it works!
Much appreciated.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.