Not yet rated

Problem

ColdFusion function DollarFormat() has no options for removing cents. Here's a function to solve the problem.

Solution

A custom function will do the trick!

Detailed explanation

Need a dollar figured displayed but without the cents?  Use this custom function to strip off the decimal and cents while maintaining parenthesis for negative amounts.

<cfscript>
        function MyDollarFormat(money_string){
            money_string = DollarFormat(money_string);
            money_string = rereplaceNoCase(money_string, '\.\d{2}', '');
            return(money_string);
        }
</cfscript>

<cfoutput>#MyDollarFormat(someMoney)#</cfoutput>


+
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. Permissions beyond the scope of this license, pertaining to the examples of code included within this work are available at Adobe.

Report abuse

Related recipes