CFLib.org – Common Function Library Project

SignedDollarFormat(amount)

Last updated September 13, 2001

author

David Grant

Version: 1 | Requires: CF5 | Library: StrLib

Description:
This UDF accept one number: amount, and returns the amount dollar formatted with a plus or minus sign instead of the regular parenthesis that dollarFormat() returns with negative numbers.

Return Values:
Returns a string.

Example:

<cfset theAmount = 12500.75>
<cfset theAmount2 = -123.99>

<cfoutput>
#signedDollarFormat(theAmount)#<BR>
#signedDollarFormat(theAmount2)#<BR>
</cfoutput>

Parameters:

Name Description Required
amount Amount to be formatted. Yes

Full UDF Source:

/**
 * Returns amount signed and dollar formatted.
 * 
 * @param amount      Amount to be formatted. 
 * @return Returns a string. 
 * @author David Grant (david@insite.net) 
 * @version 1, September 13, 2001 
 */
function signedDollarFormat(amount) {
    var sign = "";
    if (amount gt 0) sign = "+";
    else if (amount lt 0) sign = "-";
    amount = sign & dollarFormat(amount);
    return reReplace(amount,"\(|\)","","ALL"); //get rid of parenthesis
}

Search CFLib.org


Latest Additions

Raymond Camden added
QueryDeleteRows
November 04, 2017

Leigh added
nullPad
May 11, 2016

Raymond Camden added
stripHTML
May 10, 2016

Kevin Cotton added
date2ExcelDate
May 05, 2016

Raymond Camden added
CapFirst
April 25, 2016

Created by Raymond Camden / Design by Justin Johnson