Percent output format

All,

 How can I format a 97.35786984 percent to 97.35  in asp .

Thanks
UpperdeckerAsked:
Who is Participating?
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
you can also manually parse the number:

num = "97.727456"
num = Left( num, Instr( num , ".") + 2 )
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
Try:

Num = FormatNumber( "97.123456", 2)
0
 
UpperdeckerAuthor Commented:
No joy, I need it to carry out two places to the right of the decimal if less that 100%
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
works for me, if you don't want 100% to be formatted, then add a simple if statement:

num = 97.123456

if CDbl( num ) < 100 then
    num = FornatNumber( num, 2 )
end if

Response.Write num
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
you may also want to consider the Round() function:

http://www.w3schools.com/vbscript/func_round.asp
0
 
UpperdeckerAuthor Commented:
I cannot round up . There is a way to split at the . read the array to charters to the right  but I cannot remember the code.
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
What is the FormatNumber function giving you for a result? That should give you the formatted number to two places to the right of the decimal
0
 
UpperdeckerAuthor Commented:
Perfect! Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.