Value after calculation

D

Daniel

Dear all,
How to set a value into 2 decimal places after calculation in a query?
Thank you
Daniel
 
J

JohnFol

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.
 
J

Jeff Boyce

Daniel

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