User Guide Cancel

DollarFormat

 

Description

Formats a string in US Dollar format. (For other currencies, use LSCurrencyFormat or LSEuroCurrencyFormat.

Returns

A number as a string, formatted with two decimal places, thousands separator, and dollar sign. If number is negative, the return value is enclosed in parentheses. If number is an empty string, returns zero.

Category

Display and formatting functions

Function syntax

DollarFormat(number)
DollarFormat(number)
DollarFormat(number)

See also

DecimalFormatNumberFormat

Parameters

Parameter

Description

number

Number to format

Example

<!--- This example shows the use of DollarFormat --->
...
<h3>DollarFormat Example</h3>
<cfloop from = 8 to = 50 index = counter>
<cfset full = counter>
<cfset quarter = counter + (1/4)>
<cfset half = counter + (1/2)>
<cfset threefourth = counter + (3/4)>
<cfoutput>
<pre>
bill #DollarFormat(full)# #DollarFormat(quarter)#
#DollarFormat(half)# #DollarFormat(threefourth)#
18% tip #DollarFormat(full * (18/100))#
#DollarFormat(quarter * (18/100))#
#DollarFormat(half * (18/100))#
#DollarFormat(threefourth * (18/100))#
</pre>
</cfoutput>
</cfloop>
...
<!--- This example shows the use of DollarFormat ---> ... <h3>DollarFormat Example</h3> <cfloop from = 8 to = 50 index = counter> <cfset full = counter> <cfset quarter = counter + (1/4)> <cfset half = counter + (1/2)> <cfset threefourth = counter + (3/4)> <cfoutput> <pre> bill #DollarFormat(full)# #DollarFormat(quarter)# #DollarFormat(half)# #DollarFormat(threefourth)# 18% tip #DollarFormat(full * (18/100))# #DollarFormat(quarter * (18/100))# #DollarFormat(half * (18/100))# #DollarFormat(threefourth * (18/100))# </pre> </cfoutput> </cfloop> ...
<!--- This example shows the use of DollarFormat ---> 
... 
<h3>DollarFormat Example</h3> 
<cfloop from = 8 to = 50 index = counter> 
<cfset full = counter> 
<cfset quarter = counter + (1/4)> 
<cfset half = counter + (1/2)> 
<cfset threefourth = counter + (3/4)> 
<cfoutput> 
<pre> 
bill #DollarFormat(full)# #DollarFormat(quarter)# 
#DollarFormat(half)# #DollarFormat(threefourth)# 
18% tip #DollarFormat(full * (18/100))# 
#DollarFormat(quarter * (18/100))# 
#DollarFormat(half * (18/100))# 
#DollarFormat(threefourth * (18/100))# 
</pre> 
</cfoutput> 
</cfloop> 
...

Get help faster and easier

New user?