Converting float to decimal

  • In a derived column transformation, I have this LEN([Glbl Amt]) > 0 ? (DT_NUMERIC, 18, 7) [Glbl Amt] : NULL(DT_NUMERIC,18,7).

    The error I'm getting is this:

    The function "LEN" does not support the data type "DT_R8" for parameter number 1. The type of the parameter could not be implicity cast into a compatible type for the function. To perform this operation, the operand needs to be explicitly cast with a cast operator.

    What I'm trying to do is convert the field Glbl Amt from a float (data type in the excel file) to a numeric(18, 7). But I get the error above.

    Thanks for the help.

  • Have you tried using a data conversion task?

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • Hi Rs80

    I'm afraid you are unable to use LEN function directly, the character_expression argument can be

    a DT_WSTR, DT_TEXT, DT_NTEXT, or DT_IMAGE data type.

    Try LEN((DT_WSTR,15)([Glbl Amt])) > 0 ? (DT_NUMERIC,18,7)[Glbl Amt] : NULL(DT_NUMERIC,18,7)

    or

    ([Glbl Amt]) != 0 ? (DT_NUMERIC,18,7)[Glbl Amt] : NULL(DT_NUMERIC,18,7)

    Br.

    Mike

  • Thanks Mike. I'll try that.

    Phil, I wanted to use a derived column transformation before the data conversion transformation to handle blank values as NULL.

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

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