I am struggling with converting some old dts packages that use ActiveX VBScript transformations to SSIS packages. The input is an 8 character string in YYYYMMDD format. The transformation is converting it to a date if possible. If not, the value should be NULL.
Here is the dts code
TheYear = Mid(DTSSource("SHIP_DATE"),1,4)
TheMonth = Mid(DTSSource("SHIP_DATE"),5,2)
TheDay = Mid(DTSSource("SHIP_DATE"),7,2)
TheDate = TheMonth &"/"&TheDay&"/"&TheYear
If IsDate(TheDate) Then
DTSDestination("SHIP_DATE") = TheDate
End If
Here is what I have for the SSIS transformation
Dim TheYear As String
Dim TheMonth As String
Dim TheDay As String
Dim TheDate As String
If Row.SHIPDATE.Length >= 8 Then
TheYear = Row.SHIPDATE.Substring(0, 4)
TheMonth = Row.SHIPDATE.Substring(4, 2)
TheDay = Row.SHIPDATE.Substring(6, 2)
TheDate = TheMonth & "/" & TheDay & "/" & TheYear
If IsDate(TheDate) Then
Row.OutShipDate = TheDate
Else
Row.OutShipDate = Nothing
End If
Else
Row.OutShipDate = Nothing
End If
I have tried formatting OutShipDate as both date and database date. For an invalid date input string such as "00000000", I get either 1899-12-30 or 0001-01-01 in my database column depending on the dataype of OutShipDate. If I don't set Row.OutShipDate to anything in the VBScript, the SSIS execution fails completely.
Can I output a null value from the VBScript transformation?