Strange. I just tested it with this in my VBA immediate window
WorkTime=.02
?-Int(-WorkTime*2)/2
and the result is
0.5
What kind of field are you putting the value into? Both integer and Long
Integer only handle integer values (no fractional or decimal part).
If you try to put .5 into a number field that is type integer you will get
zero returned. The value will be rounded using banker's rounding. That is
numbers that end in 5 will be rounded to the nearest EVEN number.
*** 1.5 and 2.5 both round to 2
*** .5 will round to Zero
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
John - I tried the formula and it is not rounding to what I need.
examples
- if I work 0.02 hours I need it to display 0.50 hours (round up to the next
half hour)
- if I work 0.51 hours I need it to display 1.0 hours (round up to the next
whole number)
the formula below returns the following:
0.02 = 0.00
John Spencer said:
You can try the following expression.
-Int(-[WorkTime]*2)/2
It should work for you. It rounds up to the next half hour for all positive
numbers.
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
John wrote:
Hello,
I am needing some assistance with the following:
I want to take someones hours for the day and round them with the following
rule =
If you work 5.01 to 5.5 hours for that day to round to 5.5
If you work 5.51 to 5.99 hours for that day to round to 6.0 (next whole
number)
Is this something that I can do in a query?
Any help is appreciated,
John