Round Up Function

  • Hello,

     

    Can anyone help me?

     

    I want to round up my result.

    I use round ((value/60),0). It works ok when

    The result

     

    11.91 becomes 12

     

    when the result is 4.03 becomes 4 ( in mathematical theory is correct) but I want to be able to round up this to 5 instead of 4.

     

    what should I do? Any suggestion

     

    Basically I want my result appear like below

     

    11.91 becomes 12

    0.5      becomes 1

    10.1  becomes  11

    18.45 becomes 19

    40.83 becomes 41

     

    Thanks,

    Susan

     

     

  • Use round ((value/60.0)+0.5, 0)

    or even better CEILING(value/60.0)

    _____________
    Code for TallyGenerator

  • Thanks,,,

    It works well

     

     

  •  

    I tried using /60 and it did not work for me, i changed to /1.0 and it works ok? 

    round((value/1.0)+0.5, 0)


    Kindest Regards,

    JJ

  • Jimmy...

    Can't use just 60... that would imply integer math.  It has to be 60.0 to imply that it's a float calculation with decimal places.  I also believe that "value" is probably some number of seconds and Susan is trying to round the time up to the nearest whole minute.  Hence, the number "60.0".  Same would hold true for rounding minutes up to hours.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • I am using ceiling ( value/60) and it looks ok..

    I will try your suggestion, Jeff

     

    thanks every one

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply