?
Solved

Rounding results of a division to 2 decimal places

Posted on 2004-09-09
4
Medium Priority
?
215 Views
Last Modified: 2013-12-24
Rounding results of a division to 2 decimal places

I have the following lines of code in the body section of a web page which is displaying data from a database using the DateBase Results Wizard:-

<%
varDisplayAcres = fp_rs("plotarea")
varDisplayAcres = varDisplayAcres/4047
%>

I am wanting to display a plot area of land which is on an Access database in square metres, also as acres.  This involves dividing by 4047 as a good enough approximation.  I need the results to be displayed to only 2 decimal places

Here is an example of what I am having displayed at the moment:-

Plot area (sq.m.) = 590.   Acres = approx 0.145787002718063

I want the acres to be shown as 0.15 for preference, although simple truncation to 3 decimal places, i.e. as 0.145 would be acceptable.

This is I am sure simple, but I am without any textbooks/manuals where I am working at the moment.

(I know how to do this using an Access query with the calculation and the acres embedded within the Access query, but in this case I want to do the calculation outside of Access, and within the displaying web page).

Thanks for assistance.
0
Comment
Question by:Jeeva
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 12

Accepted Solution

by:
rcmb earned 400 total points
ID: 12020477
Change your code to read as follows:

<%
varDisplayAcres = fp_rs("plotarea")
varDisplayAcres = varDisplayAcres/4047
varDisplayAcres = formatnumber(varDisplayAcres,2)
%>

where ,2 gives you the number of decimal places to show.

RCMB
0
 

Author Comment

by:Jeeva
ID: 12021289
Thanks very much rcmb for prompt reponse!  Jeeva
0
 
LVL 12

Expert Comment

by:rcmb
ID: 12023570
You are welcome -- just as a side note you should be able to shorten this whole process by entering this:

<%= formatnumber((fp_rs("plotarea")/4047),2)%>

RCMB
0
 

Author Comment

by:Jeeva
ID: 12027213
Yes, that's much neater.  Thanks again.   Jeeva
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In this tutorial, I'll explain how to create an animated progress meter in a wireframe prototype developed using Axure RP 7.0 - a leading prototyping tool for designing web sites and software. (For more information about Axure and gett…
Objective of This Article In 1990’s, when I was a budding software professional, I had a lot of confusion about which stream or technology, I had to choose to build my career. In those days, I had lot of confusion like whether to choose System so…
The purpose of this video is to demonstrate how to automatically show related posts at the bottom of a blog post in WordPress. This will be demonstrated using a Windows 8 PC. Plugin “Yet Another Related Posts Plugin” will be used. Go to your…
The purpose of this video is to demonstrate how to Test the speed of a WordPress Website. Site Speed is an important metric of a site’s health. Slow site speed can result in viewers leaving your site quickly and not seeing your content. This…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question