# Getting an accurate Tax percentage - ASP Database

Hi Guys Wonder if you can help with my problem that seemed simple enough at first, but now appears to be a real pain. Basically I have created a few ASP web pages which have the following form fields on them: Net Amount (standard textbox) Tax Amount (standard textbox) Tax Rate (drop-down field) Total Amount (standard textbox) Allowing the user to populate these fields doesn't prove a problem, my problem is that when I retrieve the data that they have previously posted, I need to work out what rate to show (SELECTED) in the Tax Rate drop-down menu field. This ...

1. ## Getting an accurate Tax percentage

Hi Guys

Wonder if you can help with my problem that seemed simple enough at first,
but now appears to be a real pain.

Basically I have created a few ASP web pages which have the following form
fields on them:

Net Amount (standard textbox)
Tax Amount (standard textbox)
Tax Rate (drop-down field)
Total Amount (standard textbox)

Allowing the user to populate these fields doesn't prove a problem, my
problem is that when I retrieve the data that they have previously posted, I
need to work out what rate to show (SELECTED) in the Tax Rate drop-down menu
field. This is where the math part comes in.

My plan was to take the Tax Amount divide it by the Net Amount and then
times the result by 100. As an example, please not the following:

a) My Tax Rate drop-down menu will have a rate of 17.5.

b) My Net Amount is 200.00

c) My Tax Amount is 35.00

d) 35.00 / 200.00 * 100 = 17.5 <<< bingo I say, however:

Lets say my Net Amount is 5.00 and my Tax Amount is 0.88 I get 17.6 and if I
go for a Tax Amount of 0.87 I get 17.4.

How can I get round this?

For your ref, I'm using a MySQL DB that has the Net Amount and Tax Amount
set to a decimal data type with 3 decimal places.

Can you give me an idea of what calc I can use (ASP friendly would be really
nice) to get a more accurate output.

Thanks

Laphan

Laphan Guest 2. ## Re: Getting an accurate Tax percentage

My suggestion would be not to do the calculation in the database, but in the
ASP script. The FormatNumber function can format your output to decimal
places as needed:

FormatNumber(TaxAmount/NetAmount * 100, 3)

--
Manohar Kamath
Editor, .netWire
[url]www.dotnetwire.com[/url]

"Laphan" <newsDoNotEmailMe.co.uk> wrote in message
news:4106c7c2_3127.0.0.1...
> Hi Guys
>
> Wonder if you can help with my problem that seemed simple enough at first,
> but now appears to be a real pain.
>
> Basically I have created a few ASP web pages which have the following form
> fields on them:
>
> Net Amount (standard textbox)
> Tax Amount (standard textbox)
> Tax Rate (drop-down field)
> Total Amount (standard textbox)
>
> Allowing the user to populate these fields doesn't prove a problem, my
> problem is that when I retrieve the data that they have previously posted,
I
> need to work out what rate to show (SELECTED) in the Tax Rate drop-down
> field. This is where the math part comes in.
>
> My plan was to take the Tax Amount divide it by the Net Amount and then
> times the result by 100. As an example, please not the following:
>
> a) My Tax Rate drop-down menu will have a rate of 17.5.
>
> b) My Net Amount is 200.00
>
> c) My Tax Amount is 35.00
>
> d) 35.00 / 200.00 * 100 = 17.5 <<< bingo I say, however:
>
>
> Lets say my Net Amount is 5.00 and my Tax Amount is 0.88 I get 17.6 and if
I
> go for a Tax Amount of 0.87 I get 17.4.
>
> How can I get round this?
>
> For your ref, I'm using a MySQL DB that has the Net Amount and Tax Amount
> set to a decimal data type with 3 decimal places.
>
> Can you give me an idea of what calc I can use (ASP friendly would be
really
> nice) to get a more accurate output.
>
> Thanks
>
> Laphan
>
>
>
>

Manohar Kamath [MVP] Guest #### Posting Permissions

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