YYYYMMDD date to DB_Date in SSIS Package

  • I am trying to run a simple SSIS import from a flat file to a SQL Server database. However, I have a date stored in the YYYYMMDD format in the input file. I cannot get it to convert into the db.

    I get an error that it might loose a value as it tries to auto convert if I change the source column data type from string to date. I get an invalid cast exception if I try to just make the conversion on the SQL Server destination step.

    Does anyone have an idea of how I can fix this one?

  • hI,

    Use Derived column and put

    SUBSTRING([Column 2],4,4) + "/" + SUBSTRING([Column 2],5,2) + "/" + SUBSTRING([Column 2],7,2)

    in expression and data_type DT_DATE

    Thanks!

  • nkm has the right idea. The other thing you need to consider is that you have a "bad" value in the text file. Something like 20080631, as there are not 31 days in June. So you may need to verify that you have a valid date.

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

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