PDA

View Full Version : lenght of number?


Speedy
10-06-2005, 10:08 PM
Hi,

first of all I hope this is the right forum for this question.

What I wonder is how to round my numbers so they ALWAYS have 2 decimals when shown on my webpage.

I have the following code right now:


Set objrs = Conn.Execute("SELECT round(AVG(AMT1+0.0),2) AS medel from tbl_res Where PlayerId ='"& strpID &"' ")


but when a number that should be printed 2,60 is printed 2,6 I wonder what I did wrong (2,00 shows as 2). What is wrong? need more code? tell meand i will paste it in here.

Thanks, /S

oracleguy
10-06-2005, 10:23 PM
It is working correctly, it is just rounding it two decimal places. If you want it have the extra zeros you might want to look into using the ASP function FormatNumber() when you output it on your page.

Bullschmidt
10-13-2005, 05:57 AM
And for more on the FormatNumber() as well as other functions:

Visual Basic Scripting Edition Functions
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/vtorifunctions.asp

And if the function doesn't have to be in the SQL statement there is a VBScript Round() function.