format question

  • Hello all,

    In a query I need to multiply a int with a decimal(18,2)....but the result is always giving me 6 decimals.....like 1500.000000. How can I cast it or format it so I only shows 2 decimals?

  • use CAST to convert the data types,

    SELECT CAST('1500.000000' AS NUMERIC(18,2))

  • moramoga (5/5/2009)


    Hello all,

    In a query I need to multiply a int with a decimal(18,2)....but the result is always giving me 6 decimals.....like 1500.000000. How can I cast it or format it so I only shows 2 decimals?

    That is weird, what are the types you are multiplying? When I multiply a Decimal(18,2) with a Int, I get 2 decimals out.

    DECLARE @Dec DECIMAL(18,2),

    @int INT

    SELECT @Dec = 10.51,

    @int = 8

    SELECT @Dec * @int AS MultipliedValue

    Result : 84.08

    Cheers,

    J-F

Viewing 3 posts - 1 through 2 (of 2 total)

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