Round to 100

B

Boon

Hi,

I would like to round a number to hundreadth like this
100 -> 100
101 -> 200
150 -> 200
199 -> 200
200 -> 200

What is the best way to qrite a query to do this?

Thanks,
Boon
 
L

Lord Kelvan

roundedvalue: IIf([numberfield]>CInt(Left([numberfield],1) &
"00"),CInt(Left([numberfield],1) & "00")+100,IIf([numberfield]<100,100,
[numberfield]))

as a note this will only work with values up to 899

i dont know of a rounding function in access as i am using access 97
someone else may know though

Regards
Kelvan
 
J

John W. Vinson

Hi,

I would like to round a number to hundreadth like this
100 -> 100
101 -> 200
150 -> 200
199 -> 200
200 -> 200

What is the best way to qrite a query to do this?

Thanks,
Boon

If the field is named Num, a calculated field

-Int(-[Num]/100)*100

will do it for you. Int rounds down (or truncates), so taking Int of the
negative and then taking the negative of *that* rounds up.
 
A

Allen Browne

Here's a resource that explains various ways to round data in Access:
http://allenbrowne.com/round.html#RoundUp
The 'Rounding up' section describes what you need.

Don't forget to consider what you want with negatives, e.g. should -99 be
rounded 'up' to 0? Or should -1 be rounded 'down' to -100?
 

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