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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formatting Numbers

Status
Not open for further replies.

bigairguy

Programmer
May 10, 2005
14
US
Is there any fairly straight-forward way to format a number to include 2 places behind the decimal point, but not include the decimal places if they are trailing zeros? You can specify the number of decimal places to be shown with the FormatNumber function, but the values for the places are always displayed. I only want to display the two decimal places if they are not zero, as follows:
ex) 100000 Output: 100,000
100000.3247 Output: 100,000.32

Any ideas? Thanks.

Patrick
 
[1]
[tt]p=formatnumber(100000,0,0,0,-1)
q=formatnumber(100000.3247,2,0,0,-1)[/tt]

[2] Check out documentation for formatnumber.
[tt]FormatNumber(Expression [,NumDigitsAfterDecimal [,IncludeLeadingDigit [,UseParensForNegativeNumbers [,GroupDigits]]]])[/tt]
 
you may try a construct like the following:
Replace(FormatNumber(...), ".00", "")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks again, guys. You both have helped me out numerous times.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top