Results 1 to 6 of 6
  1. #1
    DSam is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2016
    Posts
    6

    Round up to every 0,5 decimal (i.e. 1,1 to 1,5 ; 1,4 to 1,5 ; 1,6 to 2 etc)

    Hi,


    I need to round up vaules in a table to every 0,5... How can I do that?
    I need values like 1,1 and 1,2 and 1,3 and 1,4 and 1,5 to be presented as 1,5. 1,6 to 1,9 to be rounded to 2.....
    Please help...

  2. #2
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,933
    assuming your values only go to 1 decimal place, this should work

    ((((myValue-0.1)*10) \ 5)+1)*0.5

    replace myValue with your field name

    if your values go to more than 1 decimal places, you need to modify the 0.1

    so 1.51 on above will round to 1.5

    this

    ((((myValue-0.01)*10) \ 5)+1)*0.5


    will round to 2

  3. #3
    DSam is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2016
    Posts
    6
    Thanks Ajax,
    I´ve tried your solution and it seems to work for any value with a decimal but every integer will now have 0,5 added,, so 1 becomes 1,5 and 2 becomes 2,5. I need the integer to be left as is... any idea?

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,917
    Code:
    If Int(YourValue) <> YourValue Then
       Do the rounding
    Else
       Leave it alone
    End If

  5. #5
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,933
    just tried this

    ((((1-0.1)*10) \ 5)+1)*0.5

    and it returns 1

    modify the other one to

    ((((myValue-0.01)*100) \ 50)+1)*0.5

  6. #6
    DSam is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2016
    Posts
    6

    Thumbs up Great, thanks Ajax!!

    Quote Originally Posted by Ajax View Post
    just tried this

    ((((1-0.1)*10) \ 5)+1)*0.5

    and it returns 1

    modify the other one to

    ((((myValue-0.01)*100) \ 50)+1)*0.5
    Tested and it deliver exactly what i need,, thanks!!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Convert decimal comma to decimal point
    By Hans Karlsson in forum Programming
    Replies: 3
    Last Post: 06-30-2014, 01:56 PM
  2. Always Round Up (Never Down)
    By Derrick T. Davidson in forum Queries
    Replies: 3
    Last Post: 07-23-2013, 10:08 PM
  3. round up
    By Rhubie in forum Access
    Replies: 1
    Last Post: 08-29-2012, 05:14 PM
  4. Round Up/Down 4 Decimals to 2
    By newbie in forum Access
    Replies: 6
    Last Post: 10-18-2010, 02:58 PM
  5. Replies: 1
    Last Post: 06-09-2006, 05:44 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums