Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Number Format problem 2

Status
Not open for further replies.

Swan

IS-IT--Management
Jul 13, 2001
4
0
0
US
This is the code that I have in my application to display a number:

Code:
<td valign=&quot;top&quot;>				
<font face=&quot;Verdana, Arial, Helvetica&quot; size=&quot;2&quot;>
<div>#qryworkorderlines.Quantity#</div></font>
</td>

Now, this is coming over from a database and when it shows up on the web page, it is padded with 6 decimal places. 12 shows up as 12.000000 and 6.5 shows up as 6.500000. How can I format this in coldfusion to display only 2 decimals?

 
Hi Swan,

This should work for you:

#NumberFormat(qryworkorderlines.Quantity,&quot;9999.99&quot;)#

checkout the syntax for NumberFormat, there is a lot more you can do with it.

hope that helps...
 
The only problem with numberFormat is that the mask has to be at least as long as the number being formatted. I don't know about 4.5 but 4.0 doesn't like masks which are shorter than the number. I would recommend using a dynamically created mask or just using #decimalFormat(qryworkorderlines.Quantity)# to display the number. This will put a thousands separator in but you can remove it with lsParseNumber() if necessary like this:

#lsParseNumber(decimalFormat(qryworkorderlines.Quantity))#

Hope this helps,
GJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top