#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    4
    Rep Power
    0
    Im learning...

    I have a column of Prices that are stored as 25.0000 (4 decimal places)

    What would I add to the following line to 'fix' my decimals to 0.00 (2 places)?

    Select Price from BlahTable

    Thank you.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    43
    Rep Power
    15
    I believe you can do this:

    SELECT round(price,2) AS price FROM BlahTable WHERE etc.
    Regards
    lhall

    [This message has been edited by lhallusa (edited June 30, 2000).]

    [This message has been edited by lhallusa (edited June 30, 2000).]
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    4
    Rep Power
    0
    Thank you. That did the trick. Only one small problem so far : If there are two zeros after the decimal the last one is dropped (25.0 instead of 25.00)

    I shouldnt have a problem fixing this one though.

    [This message has been edited by NSupremo (edited June 30, 2000).]
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2009
    Location
    Bangalore
    Posts
    1
    Rep Power
    0
    Try this one...

    declare @youramountorNumber as varchar(12)
    set @youramountorNumber = '1234567890'
    select convert(varchar, Convert(money, @youramountorNumber), 1) as formattedAmount

    Result
    ------
    1,234,567,890.00

    I hope this would help...
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2006
    Posts
    2,484
    Rep Power
    1752
    9 years later ...!
    The moon on the one hand, the dawn on the other:
    The moon is my sister, the dawn is my brother.
    The moon on my left and the dawn on my right.
    My brother, good morning: my sister, good night.
    -- Hilaire Belloc
  10. #6
  11. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,280
    Rep Power
    4279
    Originally Posted by SimonJM
    9 years later ...!
    and the wrong dbms
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Mar 2006
    Posts
    2,484
    Rep Power
    1752
    Originally Posted by r937
    and the wrong dbms
    Look on the bright side, it was, at least, in English ...!
    The moon on the one hand, the dawn on the other:
    The moon is my sister, the dawn is my brother.
    The moon on my left and the dawn on my right.
    My brother, good morning: my sister, good night.
    -- Hilaire Belloc

Similar Threads

  1. Limiting the number of decimal places in a calculation
    By esimonds in forum HTML Programming
    Replies: 7
    Last Post: April 1st, 2004, 11:23 AM
  2. Complex SQL to sink your teeth into!
    By lbenson in forum MySQL Help
    Replies: 3
    Last Post: November 21st, 2001, 11:04 AM
  3. Help with rounding to 2 decimal places
    By sjbates in forum Perl Programming
    Replies: 3
    Last Post: July 29th, 2001, 05:25 PM
  4. Too many decimal places
    By RedEyes in forum PHP Development
    Replies: 1
    Last Post: August 13th, 2000, 01:40 AM
  5. Displaying decimal places
    By woodgnome in forum PHP Development
    Replies: 3
    Last Post: July 13th, 2000, 11:15 PM

IMN logo majestic logo threadwatch logo seochat tools logo