ehigginbotham Posted September 26, 2012 Share Posted September 26, 2012 I have two data fields that have large numbers in them. I need to subtract one number from the other. they have two decimal places. This sounds simple enough, but I can't get it to work without FP doing some wierd formatting on the numbers, that gives me 17.00 instead of 16855.36. its like it is rounding up the first two numbers. Here is the rule as I have it currently. var account = StringToNumber(Field("ACCOUNT-ENDING")) var company = StringToNumber(Field("COMPANY-ENDING")) var total = account - company return FormatNumber("#####.##",total) // the numbers in the data are //ACCOUNT-ENDING = 66,442.44 //COMPANY-ENDING = 49,587.08 //the result of this function is 17.00 any idea what I am doing wrong? Quote Link to comment Share on other sites More sharing options...
step Posted September 26, 2012 Share Posted September 26, 2012 I think the comma is throwing off the calculation. Try this: var account = StringToNumber(Field("ACCOUNT-ENDING")[color="Red"].replace(/,/g,"")[/color]) var company = StringToNumber(Field("COMPANY-ENDING")[color="red"].replace(/,/g,"")[/color]) Quote Link to comment Share on other sites More sharing options...
ehigginbotham Posted September 28, 2012 Author Share Posted September 28, 2012 That worked perfectly. What does the g stand for? thanks for your help Quote Link to comment Share on other sites More sharing options...
step Posted September 28, 2012 Share Posted September 28, 2012 (edited) the "g" makes the change globally. If the dollar amount were to contain more than 1 comma, it would remove all of them. Glad that worked for you! Edited October 8, 2012 by step Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.