Decimal points for displaying prices

# Thread: Decimal points for displaying prices

1. Werner Guest

## Decimal points for displaying prices

Hi there,<BR><BR>I have a site with an underlying access database to store some product information. Few of the columns of my product table have to do with pricing. I have set the column properties to "currency" via the designview of access. I also set up the decimal values of these columns to "2".<BR><BR>Here is my point:<BR>when the ASP-page has to display a price of \$80,00 it only shows me \$80 without the two expected decimals. I tried to solve this with the follwing code:<BR><BR>& round(objRecordset("Price_USD"),2) & <BR><BR>This didn&#039t help me out either...<BR><BR>Does someone has anny suggestion to tackle this problem?<BR><BR>Thanks in advance,<BR>Werner Vaarwerk<BR>w.vaarwerk@home.nl<BR>

2. dc
Senior Member
Join Date
Dec 1969
Posts
113

## RE: Decimal points for displaying prices

Hi,<BR><BR>Here&#039s a bit of a clumbsy answer, but it will work!<BR><BR>Assuming your price number data is in variable "price" then<BR><BR>price_string=cstr(price*100)<BR>sepera tor="."<BR>out_text=""<BR><BR>out_text=left(price_ string,len(price_string)-2)+seperator+right(price_string,2)<BR><BR>What happens is your number in dollars from the database (say 80) is turned into a string after being multiplied by 100. This gives a string of "8000". We then take the left part of the string up until the last two characters ("80"), followed by our seperator (".") followed by the last two digits ("00") giving an out_text string of "80.00".<BR><BR>This should also sort out the same problem you will have with prices like 40.90 (which will come out as 40.9). This will go from 40.9 to 4090 to "40" "." "90".<BR><BR>Bit clumbsy, but hey it works!<BR><BR>DC

#### Posting Permissions

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