techxplore blog
10Oct

ColdFusion Format Number String

Number output of ColdFusion web application sometimes needs formatting. It was requested by an office mate to format the number separated by a comma for readability. The comma, (“,”) separates every third decimal place of a comma, and it is also referred to as the thousands separator.

ColdFusion syntax for number format:
#NumberFormat( 123456789, “,” )#

Code before using NumberFormat:

The total amount #qrySource1.totalamount# + #qrySource2.totalamount# = # qrySource1.totalamount + qrySource2. totalamount # should be the same

Output before using NumberFormat:

ColdFusion before Numberformat Output

ColdFusion before Numberformat Output

Code after using NumberFormat:

The total amount #qrySource1.totalamount# + #qrySource2.totalamount# = # NumberFormat(qrySource1. totalamount + qrySource2. totalamount , "," )# should be the same

Output after using NumberFormat:

ColdFusion after Numberformat Output

ColdFusion after Numberformat Output

In ColdFusion, it is easy to implement the thousand separator number format with the above syntax.

Leave a Reply