Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / November 2007

Tip: Looking for answers? Try searching our database.

Rounding up to 2 decimals

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
talibm - 31 Oct 2007 21:55 GMT
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
Signature

tm

Ofer Cohen - 31 Oct 2007 23:09 GMT
Try

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

Signature

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:
[quoted text clipped - 4 lines]
> 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
talibm - 01 Nov 2007 01:38 GMT
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
Signature

tm

> Try
>
[quoted text clipped - 8 lines]
> > 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
Ofer Cohen - 01 Nov 2007 11:14 GMT
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)

Signature

Good Luck
BS"D

> 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
[quoted text clipped - 14 lines]
> > > 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
talibm - 01 Nov 2007 20:11 GMT
Thanks so much!
Signature

tm

> I realy don't know, I tried and it worked.
>
[quoted text clipped - 34 lines]
> > > > 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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.