Error casting a string as a date returned from an EP task

  • Hi -- I have an Execute Process task that returns a date as a string like this:

    yyyy-mm-dd\r

    where \r are carriage return, newline.

    In the EP task I assign this to a variable of type string. This works fine.

    In the package I also have a variable defined as type DateTime. I want to assign this variable the date value returned from the EP task. So, I defined it with an expression like this:

    (DT_DATE) SUBSTRING(@[User::Date_in_a_string], 1, 10)

    I initialized Date_in_a_string to "1900-01-01\r". Before running the EP task, the conversion works just fine. That is, I edit the DateTime variable expression and click Evaluate Expression and it returns the correct date (converted from the default value of Date_in_a_string) without errors.

    However, when executing the EP task, the package bombs with the message:

    Error: The type of the value being assigned to variable "User::Date_in_a_string" differs from the current variable type. Variables may not change type during execution. Variable types are strict, except for variables of type Object.

    Any idea why this is happening and how I can successfully convert the date received from the EP task to a DateTime-typed variable in SSIS?

    Does the typecast (DT_DATE) not return a DateTime type? If not, what does?

    Gerald Britton, Pluralsight courses

  • Solved it!

    My Bad. I chose the wrong variable for StdOut in the EP task

    Gerald Britton, Pluralsight courses

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

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