Rounding up to 2 decimals

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello Access Nation, I'm having a problem rounding up to two decimals. I have
an IIF statement iin my query:
RegAmt:
IIf([Exempt]="Y",-Int(-[AnnualPay]*[Increase_Percent]),Round([PayRate]*[Increase_Percent],2))
It correct rounds the annualpay to a whole number, but payrate needs to
round up to two decimals, e.g., .3117 should round up to .32. The way I have
it now it rounds to .31. I've tried everything I could but I can't get it to
work. Any help that you can give me is greatly appreciated. Thanks
 
Try

IIf([Exempt]="Y",-Int(-[AnnualPay]*[Increase_Percent]),Int([PayRate]*[Increase_Percent]*100+.99)/100)
 
Thank you Ofer! It worked like a charm. If you don't mind could you explain
to me how this works. I've looked at several lines of code like this and
can't quite understand how it works. Thanks again for your help.

Talib
--
tm


Ofer Cohen said:
Try

IIf([Exempt]="Y",-Int(-[AnnualPay]*[Increase_Percent]),Int([PayRate]*[Increase_Percent]*100+.99)/100)

--
Good Luck
BS"D


talibm said:
Hello Access Nation, I'm having a problem rounding up to two decimals. I have
an IIF statement iin my query:
RegAmt:
IIf([Exempt]="Y",-Int(-[AnnualPay]*[Increase_Percent]),Round([PayRate]*[Increase_Percent],2))
It correct rounds the annualpay to a whole number, but payrate needs to
round up to two decimals, e.g., .3117 should round up to .32. The way I have
it now it rounds to .31. I've tried everything I could but I can't get it to
work. Any help that you can give me is greatly appreciated. Thanks
 
I realy don't know, I tried and it worked.

Now seriously
There is no function that round up,
Most will round down if under .5 and up if it's above.

but there is a function that round down and it's - Int, but the Int round
with no decimal.
So, because you wanted tow decimal places I multiplied the number by 100 so
I can round it to a whole number and then after rounding the number I devided
it back by 100 to create the two decimal places.
Because the Int round down and you wanted it to round up, adding the .99 to
the number allow the round down (of the int) to look like a round up to the
desired number.

I hope it make sense because I'm getting confused now.
But as the wise man said "It work, don't touch"


IIf([Exempt]="Y",-Int(-[AnnualPay]*[Increase_Percent]),Int([PayRate]*[Increase_Percent]*100+.99)/100)


--
Good Luck
BS"D


talibm said:
Thank you Ofer! It worked like a charm. If you don't mind could you explain
to me how this works. I've looked at several lines of code like this and
can't quite understand how it works. Thanks again for your help.

Talib
--
tm


Ofer Cohen said:
Try

IIf([Exempt]="Y",-Int(-[AnnualPay]*[Increase_Percent]),Int([PayRate]*[Increase_Percent]*100+.99)/100)

--
Good Luck
BS"D


talibm said:
Hello Access Nation, I'm having a problem rounding up to two decimals. I have
an IIF statement iin my query:
RegAmt:
IIf([Exempt]="Y",-Int(-[AnnualPay]*[Increase_Percent]),Round([PayRate]*[Increase_Percent],2))
It correct rounds the annualpay to a whole number, but payrate needs to
round up to two decimals, e.g., .3117 should round up to .32. The way I have
it now it rounds to .31. I've tried everything I could but I can't get it to
work. Any help that you can give me is greatly appreciated. Thanks
 
Thanks so much!
--
tm


Ofer Cohen said:
I realy don't know, I tried and it worked.

Now seriously
There is no function that round up,
Most will round down if under .5 and up if it's above.

but there is a function that round down and it's - Int, but the Int round
with no decimal.
So, because you wanted tow decimal places I multiplied the number by 100 so
I can round it to a whole number and then after rounding the number I devided
it back by 100 to create the two decimal places.
Because the Int round down and you wanted it to round up, adding the .99 to
the number allow the round down (of the int) to look like a round up to the
desired number.

I hope it make sense because I'm getting confused now.
But as the wise man said "It work, don't touch"


IIf([Exempt]="Y",-Int(-[AnnualPay]*[Increase_Percent]),Int([PayRate]*[Increase_Percent]*100+.99)/100)


--
Good Luck
BS"D


talibm said:
Thank you Ofer! It worked like a charm. If you don't mind could you explain
to me how this works. I've looked at several lines of code like this and
can't quite understand how it works. Thanks again for your help.

Talib
--
tm


Ofer Cohen said:
Try

IIf([Exempt]="Y",-Int(-[AnnualPay]*[Increase_Percent]),Int([PayRate]*[Increase_Percent]*100+.99)/100)

--
Good Luck
BS"D


:

Hello Access Nation, I'm having a problem rounding up to two decimals. I have
an IIF statement iin my query:
RegAmt:
IIf([Exempt]="Y",-Int(-[AnnualPay]*[Increase_Percent]),Round([PayRate]*[Increase_Percent],2))
It correct rounds the annualpay to a whole number, but payrate needs to
round up to two decimals, e.g., .3117 should round up to .32. The way I have
it now it rounds to .31. I've tried everything I could but I can't get it to
work. Any help that you can give me is greatly appreciated. Thanks
 
Back
Top