Results 1 to 4 of 4

Thread: Help with Decimal Roundings

  1. #1
    Fanatic Member vuyiswamb's Avatar
    Join Date
    Jan 07
    Location
    South Africa
    Posts
    780

    Help with Decimal Roundings

    hi Guys , i am a bit stuck here

    i have this value "0.833333333333333"

    and i want the asnwer to be 83 , i tried this


    Code:
    SELECT ROUND(0.833333333333333,2)
    but it does not work

  2. #2
    PowerPoster BruceG's Avatar
    Join Date
    May 00
    Location
    New Jersey (USA)
    Posts
    2,589

    Re: Help with Decimal Roundings

    try:
    Code:
    SELECT ROUND(0.833333333333333 * 100,0)
    "It's cold gin time again ..."

    Check out my website here.

  3. #3
    Frenzied Member
    Join Date
    Sep 02
    Location
    Columbus, Ohio
    Posts
    1,814

    Re: Help with Decimal Roundings

    This will bring back "83".

    select convert(decimal(12,0),ROUND(0.833333333333333 * 100,0))

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 02
    Posts
    21,655

    Re: Help with Decimal Roundings

    "but it does not work" -- I beg to differ... it does work... it's doing exactly what you told it to do... round to two decimal places (.83). just so happens that the result isn't what you want... (83)
    There's two solutions... 1) multiply it by 100 then round to 0 decimal places...as the previous posters did.... or, round to 2 decimal places THEN multiply by 100.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.-I also subscribe to all threads I participate, so there's no need to pm when there's an update.*
    *Proof positive that searching the forums does work: View Thread *
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *
    * Use Offensive Programming, not Defensive Programming. * On Error Resume Next is error ignoring, not error handling(tm).
    "There is a major problem with your code, and VB wants to tell you what it is.. but you have decided to put your fingers in your ears and shout 'I'm not listening!'" - si_the_geek on using OERN

Posting Permissions

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