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
}
blog comments powered by Disqus

Search CFLib.org


Latest Additions

Kevin Cotton added
date2ExcelDate
May 5, 2016

Raymond Camden added
CapFirst
April 25, 2016

Chris Wigginton added
loremIpsum
January 18, 2016

Gary Stanton added
calculateArrival...
November 19, 2015

Sebastiaan Naafs - van Dijk added
getDaysInQuarter
November 13, 2015

Created by Raymond Camden / Design by Justin Johnson