Thursday, April 3, 2008

Datetime transformation with SSIS

After doing a lot of failed transformation with some date columns in SSIS, with a very poor manually entered source data, I'll find the definitive solution to the datetime transformations from string.

I have included a script component into the dataflow to perform the transformation, with the following code:


Try
Row.ConvertedDate = DateTime.Parse(Row.Date.Substring(0, 2) + "/" + Row.Date.Substring(2, 2) + "/" + Row.Date.Substring(4, 4))
Catch
Row.ConvertedDates = DateTime.MinValue
End Try


With that approach you have the abbility of perform some advanced transformations in the Catch statement.