Results 1 to 7 of 7
  1. #1
    Join Date
    Mar 2004
    Location
    chicago
    Posts
    26

    Unanswered: rounding up to .5 from 4 decimal places

    Hi.


    I have data with 4 decimal places that need to be rounded up to the nearest .5 in a query.

    1.0222 = 1.5
    -.2345 = 0
    349.6793 = 350.0

    The way i did it in '97 is too complex for 2000. At least that is what the message error tells me. I have a feeling i wasn't doing it too efficiently to begin with.

    Can you please help me?

  2. #2
    Join Date
    Jan 2004
    Posts
    40

    Re: rounding up to .5 from 4 decimal places

    just take the decimal part of the number,

    if decimal part is < .5 than add .5 to integer part of the number
    if decial part is > .5 than add 1 to integer part of the number

  3. #3
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Rounding to 4 digits
    &nbsp;&nbsp;yourRoundendNum = (Int((yourNum + 0.0005) * 1000) / 1000)

  4. #4
    Join Date
    Mar 2004
    Location
    chicago
    Posts
    26

    rounding

    Thanks...i'll shall try both methods!

  5. #5
    Join Date
    Mar 2004
    Location
    chicago
    Posts
    26

    Question pulling decimals from whole numbers in a query

    I am trying to isolate the decimal portion of a number from its whole number in a query.

    I thought of MID, but the decimal point is not always at a fixed point

    I want .6333 from 78.6333
    .5 from 489.5

    Any help would be appreciated. Thanks.

  6. #6
    Join Date
    Nov 2003
    Posts
    267
    VAr1 = 78.6333 (assuming it is a string)

    Var2 = Mid(Var1,instr(var1,1,".")+1)

    var2 is now equal to .6333

    S-

  7. #7
    Join Date
    Mar 2004
    Location
    chicago
    Posts
    26
    thanks...this is really helping me cut some baby steps.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •