Page 1 of 1

FormatNumber as currency - but need a decimal

Posted: Tue Dec 29, 2015 12:56 pm
by RyanHulslander
Question - is there an easy way to use "FormatNumber" and take a fixed length field such as 00053084 and convert it to $530.84 ?

What I'm trying to do is take a number that is in a fixed-length record and display it with the decimal before the rightmost two digits. Everything I see in the FormatNumber pattern shows me how to add in a ".00" if it's not there, or perform rounding if the number already contains a decimal. In this case there is no decimal but the #.## pattern is implied with the rightmost two digits.

Is there a way to invoke FormatNumber on this or do I need to come up with a slightly more elaborate function to take the number convert it to a string and chop it up for display accordingly?

Thanks!

Ryan

Re: FormatNumber as currency - but need a decimal

Posted: Tue Dec 29, 2015 1:19 pm
by Support_Rick
Ryan,

The easiest way to do this is to just format the number as needed using the "/100" method. Since the value is implied as 2 decimals, this can be done like this:


Using MyNumber = 00053084

<setVariable label="setVar: FormattedNumber" name="FormattedNumber" value="${FormatNumber(MyNumber/100, &apos;$####.##&apos;)}" version="2.0" />


The output log will show this:

Variable 'FormattedNumber' was created and set to '$530.84'.