[crystal-reports] Convert string to number field

I have a Database field whose datatype is String in Crystal Reports. How can I convert it to a number value?

This question is related to crystal-reports

The answer is


Within Crystal, you can do it by creating a formula that uses the ToNumber function. It might be a good idea to code for the possibility that the field might include non-numeric data - like so:

If NumericText ({field}) then ToNumber ({field}) else 0

Alternatively, you might find it easier to convert the field's datatype within the query used in the report.