tags:

views:

345

answers:

1

I want to be able to convert a string number such as "1,427.76" to a number in coldfusion but the comma is making it fail. Is there a simple way to do it besides having to remove the comma?

<cfset string = "1,427.75">

<cfset number = string * 100>

The error occurs when trying to perform mathematical operations on it. If the comma is removed it works just fine but I'm getting the comma from a database calculation.

+10  A: 

I know you can use LSParseNumber:

<cfset string = "1,427.75">

<cfset number = LSParseNumber(string) * 100>
derivation
That worked great, thanks!
Scott Chantry
@Scott Chantry if derivation's answer worked for you, don't forget to choose it as the Accepted answer. :)
mwc