Is there a way to round up to the next whole number in a query?
Is there a way to round up to the next whole number in a query?
You could create your own User Defined Function to do it, or use a formula something like this:
RoundUP: IIF([NumField] =Int([NumField]),[NumField],Int([NumField])+1)
where
NumField is the name of your field.
Wouldn't
Int(NumField+1)
work for all positive numbers?.
Int() truncates the decimal places, so both 3.9 and 3.1 would result in 4. To handle negative numbers, iif(NumField<0,-INT(ABS(NumField)+1),Int(NumField)+1)
That was great. Thanks. It worked perfectly.
I don't think so.Wouldn't
Int(NumField+1)
work for all positive numbers?.
What if the number is exactly equal to a whole number (i.e. 3)?
Then it round return 4 instead of 3.
Yep, you're right. The NumField=int(numfield) condition would have to be added.