Sql Problem...

1. AnotherNewBie Guest

## Sql Problem...

I am using SUM FUnction in sql to add up numbers in the databse to give me a result. I am using &#060;%= FormatNumber( totalcost , 2, -2, -2, -2) %&#062;.<BR><BR>The problem comes when I am adding numbers with decimals eg. 200.67+100.00+200.00 shd actually round up to 501.00 but it rounds up to 500.00. Can anyone help on this<BR><BR>Thnx

2. Senior Member
Join Date
Dec 1969
Posts
636

## RE: Sql Problem...

3. New ASP Guest

## RE: Sql Problem...

Try to do this:<BR><BR>&#060;%= FormatNumber( CINT(totalcost) , 2, -2, -2, -2) %&#062;.<BR>

4. AnotherNewBie Guest

## RE: Sql Problem...

This is a smaller chunk of the entire response page. That complete code is a huge one... so I have simplified and giving .. And I have posted an error previously, I am not using SUM over here... Sum is for the SUM of all the entries in totalcost. That is fine, since the totalcost is always round... Thanx for ur help<BR><BR>&#060;%<BR>dim totalcost<BR>totalcost = Int(Request("costa")) + Int(Request("costb")) +Int(Request("costc"))<BR>%&#062;<BR>&#060;html&#0 62;<BR>&#060;head&#062;<BR>&#060;/head&#062;<BR>&#060;body&#062;<BR>&#060;table width="500" border="0" cellspacing="0" cellpadding="0"&#062;<BR> &#060;tr&#062; <BR> &#060;td&#062;Cost 1. &#060;%=Request("costa")%&#062;&#060;/td&#062;<BR> &#060;/tr&#062;<BR> &#060;tr&#062; <BR> &#060;td&#062;Cost 2. &#060;%=Request("costb")%&#062;&#060;/td&#062;<BR> &#060;/tr&#062;<BR> &#060;tr&#062; <BR> &#060;td&#062;Cost 3. &#060;%=Request("costc")%&#062;&#060;/td&#062;<BR> &#060;/tr&#062;<BR> &#060;tr&#062;<BR> &#060;td&#062;Total Cost. &#060;%= FormatNumber( totalcost , 2, -2, -2, -2) %&#062;&#060;/td&#062;<BR> &#060;/tr&#062;<BR>&#060;/table&#062;<BR>&#060;/body&#062;<BR>&#060;/html&#062;

5. New ASP Guest

## RE: Sql Problem...

totalcost = <BR>CINT(<BR>cdbl((Request("costa")) + <BR>cdbl(Request("costb")) +<BR>cdbl(Int(Request("costc"))<BR>)<BR>

6. New ASP Guest

## Oooops..

totalcost = <BR>CINT(<BR>cdbl(Request("costa")) + <BR>cdbl(Request("costb")) +<BR>cdbl(Request("costc"))<BR>)

7. Senior Member
Join Date
Dec 1969
Posts
636

## RE: Sql Problem...

From what I can tell (I&#039;m still new to this myself) you haven&#039;t rounded the number yet.<BR><BR>Dim holdcost<BR>holdcost = FormatNumber( totalcost , 2, -2, -2, -2)<BR><BR>Round(holdcost, 2)<BR><BR>Let me know if this works.

8. AnotherNewBie Guest

## RE: Sql Problem...

Thanx Everyone... I will try all options<BR><BR>Thanx for your time

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•