Search code examples
ssistype-conversionstring-to-datetime

Convert yymmdd to datetime using ssis derived column


Below are the strings representing date of birth (yymmdd). I want to convert it into datetime format and load into a database using ssis. How can I do it? In my derived column I have (DT_DATE)(SUBSTRING([Drv DOB],1,2) + "-" + SUBSTRING([Drv DOB],3,2) + "-" + SUBSTRING([Drv DOB],5,2)), but it's not working.

I GET THESE ERRORS:

  1. [Derived Column [2]] Error: An error occurred while attempting to perform a type cast.
  2. [Derived Column [2]] Error: SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR. The "Derived Column" failed because error code 0xC0049064 occurred, and the error row disposition on "Derived Column.Inputs[Derived Column Input].Columns[Drv DOB]" specifies failure on error. An error occurred on the specified object of the specified component. There may be error messages posted before this with more information about the failure.

•470324 •470324 •470209 •101 •0


Solution

  • YEAR have 4 digits not 2, so it would be:

    (DT_DATE)("20" + SUBSTRING([Drv DOB],1,2) + "-" + 
                     SUBSTRING([Drv DOB],3,2) + "-" + 
                     SUBSTRING([Drv DOB],5,2))