Having Problems with DATEDIFF in derived column expression
hi all
i''m using sql server 2008. 'm using derived column in package , have 2 date fields (dtstartdate,dtenddate) coming flat file source. used derived column difference between 2 dates , add new field. i'm using following function in expression part.
datediff("dd",dtstartdate,dtenddate) , reason highlighted in red , when clicked ok showing me following error message:
title: microsoft visual studio
------------------------------
error @ data flow task [compute inactive days [370]]: function "datediff" not support data type "dt_wstr" parameter number 2. type of parameter not implicitly cast compatible type function. perform operation, operand needs explicitly cast cast operator.
error @ data flow task [compute inactive days [370]]: evaluating function "datediff" failed error code 0xc0047089.
error @ data flow task [compute inactive days [370]]: computing expression "datediff("dd", dtwarrantstart,dtwarrantend )" failed error code 0xc00470c5. expression may have errors, such divide zero, cannot detected @ parse time, or there may out-of-memory error.
error @ data flow task [compute inactive days [370]]: expression "datediff("dd", dtwarrantstart,dtwarrantend )" on "output column "inactivedays" (384)" not valid.
error @ data flow task [compute inactive days [370]]: failed set property "expression" on "output column "inactivedays" (384)".
------------------------------
additional information:
exception hresult: 0xc0204006 (microsoft.sqlserver.dtspipelinewrap)
------------------------------
buttons:
ok
------------------------------
i checked data file , not see nulls or zero's in either of datefields. can please point me i'm going wrong?
then tried following in expression "(dtwarrantstart > 0 ? (dtstartdate - dtenddate) >= 0 ? (dtwarrantstart - dtwarrantend) : -1) : 0)" , still no luck.
thanks
sv
the date fields flat file unicode (dt_wstr) , need cast them datetime before applying datediff function. try this: datediff("dd",(dt_dbtimestamp)dtstartdate,(dt_dbtimestamp)dtenddate)
note: above expression not checking nulls or invlaid dates. in order handle these checks please modify expression
nitesh rai- please mark post answered if answers question
SQL Server > SQL Server Integration Services
Comments
Post a Comment