sql - outputting null values when converting vb transformation from dts to ssis -
i struggling converting old dts packages use activex vbscript transformations ssis packages. input 8 character string in yyyymmdd format. transformation converting date if possible. if not, value should null.
here 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) dtsdestination("ship_date") = thedate end if
here have ssis transformation
dim theyear string dim themonth string dim theday string dim thedate string if row.shipdate.length >= 8 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) row.outshipdate = thedate else row.outshipdate = nothing end if else row.outshipdate = nothing end if
i have tried formatting outshipdate both date , database date. invalid date input string such "00000000", either 1899-12-30 or 0001-01-01 in database column depending on dataype of outshipdate. if don't set row.outshipdate in vbscript, ssis execution fails completely.
can output null value vbscript transformation?
should not convert date....
row.outshipdate = cdate(thedate)
is db column set allow null?
update
if isdate(thedate) row.outshipdate = cdate(thedate) else row.outshipdate = dbnull.value end if
another update...
if isdate(thedate) row.outshipdate = datetime.parse(thedate("mm/dd/yyyy")) else row.outshipdate = directcast(nothing, system.nullable(of datetime)) end if
this worked me....
dim thedate string = "36/29/2014" 'dim thedate string = "4/9/2014" dim ddb date if isdate(thedate) ddb = cdate(thedate) else ddb = nothing end if
Comments
Post a Comment