Value after calculation

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Dear all,
How to set a value into 2 decimal places after calculation in a query?
Thank you
Daniel
 
Hi Daniel, I just read the other replies you had and it's clear you are not
after formatting the output, but storing the answer exactly.

Firstly, you cannot use single / double as they are floating point and prone
to the limitations of representing fractions from binary. Can I suggest you
use a currency data type as it's a scaled integer and does not have the same
problem?

If the calculation results in a number > 2dp you have to decide how you are
going to truncate it.

For example, 20 / 3 is 6.66666666 and so on. Do you want to see 6.67, or
6.66? Have a look at these differrent methods.

Round(20/3, 2) = 6.67
Format (20/3, "0.00") = 6.67
Int((20/3) * 100 ) / 100 = 6.66


Can I also suggest that the calculation is not done in the query (unless
it's for an export / running sums), but rather on the form / report showing
the results? It will not only improve performance (as it's only done for
records displayed), but you have greater control over how it looks.
 
Daniel

I'm not sure what you mean by "set a value into 2 decimal places"? Are you
describing "rounding"?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top