You need to format a number as a US currency for output.
The dollarFormat() function takes a number as its single parameter, and returns a formatted String. The following formatting is added to the string: two decimal places, thousandths separator, and a dollar sign. Furthermore, if the number is negative, it will be wrapped in parentheses.
This question was written by Jeremy Petersen.
It was last updated on January 9, 2006 at 9:29:46 AM EST.
CFML Referenced
Categories
Comments
Comment made by Chuck J on January 9, 2006 at 3:52 PM
If you don't want to display the cents (.00), you could do this:
<cfset testNum = -1500> <cfoutput>#replace(dollarFormat(testNum), ".00", "")#</cfoutput> ($1,500)
This way if you are formatting large prices (cars, houses, etc.) you don't have to display the .00's
Comment made by Brendon Pascoe on October 30, 2006 at 6:07 PM
Thanks Jeremy, I used your tips to get it working on a new site I am developing here: http://stradamotosport.co.nz.wehostwebsites.com/details.cfm?recordID=17
Thanks mate, appreciate your tip. Brendon
Add a Comment