Two digits to the right of the decimal point

  • Hi,

    I would like to have 2 digits to the right of the decimal point, but I cannot do this.

     

    Convert(money, (SUM(CASE WHEN SHKZG = 'S' THEN DMBTR *(-1) ELSE DMBTR END)), 0)

    I set types 0, but I have always 4 digits, e. i. 172670.8839-->172670.88

    Why? Could I try any other options?

    Thanks

     

  • Hi,

    did you try already this ?

    CAST(expression AS DECIMAL (10,2))

    10 = Number of digits in a number

    2 = Number of digits right after the decimal point

    Regards,

    Jan

  • Money Datatype always has four digits to the right of the decimal place.

    Jan's example above of using DECIMAL (x,2)  will reduce the number of decimal places.


    Julian Kuiters
    juliankuiters.id.au

  • And why

    In the following table, the column on the left represents the style value for money or smallmoney conversion to character data.

    ValueOutput
    0 (default)No commas every three digits to the left of the decimal point, and two digits to the right of the decimal point; for example, 4235.98.
    1Commas every three digits to the left of the decimal point, and two digits to the right of the decimal point; for example, 3,510.92.
    2No commas every three digits to the left of the decimal point, and four digits to the right of the decimal point; for example, 4235.9819.

    thanks

  • That is correct. Conversion from money to charachter... However, in your example, you're converting to money, not char. 

    I guess what you want is like this...

    declare @m money

    set @m = 172670.8839

    select convert(varchar(12), @m, 0)

    ------------

    172670.88

    /Kenneth

     

     

     

  • Yes,

    thank you, that is what I need.

    zdenek

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

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