Solved

Rounding results of a division to 2 decimal places

Posted on 2004-09-09
4
211 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 100 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
wordpress plugin to view newspaper 3 60
What xml editor to use. 8 107
Advice on what platform to use for a web app for AWS 3 119
Windows Tool to Build Android and iOS App 3 145
When deciding to adopt any help desk solutions many factors should be explored before taking decisions. This will change from business to another but in general there are some kind of rule of thumb. Here are some quick tips: Do we need only ticket…
When setting up new project requests for our site, one of the most powerful tools our team has available to use is Axure (http://www.axure.com/). It’s a tool for creating software and web prototypes that can function and interact as if it were the a…
The purpose of this video is to demonstrate how to connect a WordPress website to Google Analytics. This will be demonstrated using a Windows 8 PC Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php :…
The purpose of this video is to demonstrate how to properly insert a Vimeo Video into a WordPress site or Blog. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp…

739 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