Round to the nearest half hour

T

Tandy

I am making a query where I divde a field in my query (Week Hours) divided by
5 to get Daily Hours. I would like that number to be rounded to the nearest
half hour.

Example: 2.01-2.24=2
2.25-2.74=2.5
2.75-2.99=3

Any help would be greatly appreciated!
 
M

Michel Walsh

Hi,



0.5 * INT( 0.5+ value / CDec(0.5) )


Hoping it may help,
Vanderghast, Access MVP
 
T

Tandy

I used what you give me, 0.5*INT(0.5+[Week Hours]/CDec(0.5)), and it told me
"The expression you entered has a function containing the wrong number of
arguments."
 
M

Michel Walsh

Hi,

The dot is decimal, not a list delimiter?


In the immediate (debug) window (Ctrl_G), try :

? 0.5* INT( 0.5 + 3.212 / CDec(0.5) )




It should return 3.


Hoping it may help,
Vanderghast, Access MVP


Tandy said:
I used what you give me, 0.5*INT(0.5+[Week Hours]/CDec(0.5)), and it told
me
"The expression you entered has a function containing the wrong number of
arguments."

Michel Walsh said:
Hi,



0.5 * INT( 0.5+ value / CDec(0.5) )


Hoping it may help,
Vanderghast, Access MVP
 
Top