Convert string to number field

2019-04-22 05:17发布

问题:

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

回答1:

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.