Round to nearest quarter number

C

Cy

Ok, I'm sure this is pretty easy, but I just can't seem to figure it
out.

I have a table, that has a price for a service. I then take a
standard rate that we are trying to make per our and divide that into
the price to get estimated hours. Easy enough to do in a query. The
hard part, is that I'd like to convert that into the nearest quarter
hour. Example, if the price is $42 and we are trying to produce at
$35, the result would come out to 1.2. However, I would like that to
convert to the nearest quarter or 1.25. Another example, $505 / $35
comes to 14.428... I would like it to be 14.5.

Any thoughts or suggestions is helpful here.

Thanks.
 
S

Spektre

The syntax varies depending on where you want to do this but the algorithm is:

rounded_result = INT(4*result+0.5)/4

So for example in your example where the result is 1.2

rounded_result = INT(4*1.2+0.5)/4
=INT(5.3)/4
=5/4 = 1.25

rounded_result = INT(4*14.428+0.5)/4
=INT(58.212)/4
=58/4 = 14.5
 

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