Round to 0.5

G

Guest

I need a formula, in a report or query, that will round my calculated result
to X.5 if the result has a decimal. Example: 2.6, 2.2, 1.9, 1.1 would be
changed to 2.5,2.5,1.5,1.5. If the result is a whole number then there is no
change. I need this for inventory counting whole/half bottles. Thanks, Dan
 
J

Joseph Meehan

Dan said:
I need a formula, in a report or query, that will round my calculated
result to X.5 if the result has a decimal. Example: 2.6, 2.2, 1.9,
1.1 would be changed to 2.5,2.5,1.5,1.5. If the result is a whole
number then there is no change. I need this for inventory counting
whole/half bottles. Thanks, Dan

How about multiplying by 2 rounding to whole number (integer) then
dividing by 2?
 
V

Van T. Dinh

IIf(([Value] - Int([Value])) > 0, Int([Value]) + 0.5, [Value])

It might be possible for truncation errors to creep in so you need to test
the sample boundary values, e.g. 2.9999999999, 3, 3.000000001 and the likes
....
 

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

Top