Not able to convert datetime to string in SSIS Expression

0

I am using ssis expression to add a day to a project parameter. Project parameter and out put variable both are string datatype. Please see below code

SUBSTRING((DT_STR,30, 1252) DATEADD("dd",1,(DT_DBDATE)@[$Project::Proj_End_Date]), 1, 10)

The above is working fine when date passed as "2017-03-10" but it is failing when the Proj_End_Date value is blank. I am getting this below error.

TITLE: Expression Builder

Expression cannot be evaluated.

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%C2%AE%20Visual%20Studio%C2%AE%202015&ProdVer=14.0.23107.0&EvtSrc=Microsoft.DataTransformationServices.Controls.TaskUIFramework.TaskUIFrameworkSR&EvtID=FailToEvaluateExpression&LinkId=20476

------------------------------ ADDITIONAL INFORMATION:

Error code 0x80020005 occurred attempting to convert from data type DT_WSTR to data type DT_DBDATE.

Casting expression "@[$Project::Proj_End_Date]" from data type "DT_WSTR" to data type "DT_DBDATE" failed with error code 0xC00470C2.

Evaluating function "DATEADD" failed with error code 0xC00470C4.

Casting expression "DATEADD("dd",1,(DT_DBDATE)@[$Project::Proj_End_Date])" from data type "DT_DBTIMESTAMP" to data type "DT_STR" failed with error code 0xC00470C5.

Error code 0x80020005 occurred attempting to convert from data type DT_WSTR to data type DT_DBDATE.

Casting expression "@[$Project::Proj_End_Date]" from data type "DT_WSTR" to data type "DT_DBDATE" failed with error code 0xC00470C2.

Evaluating function "DATEADD" failed with error code 0xC00470C4.

Casting expression "DATEADD("dd",1,(DT_DBDATE)@[$Project::Proj_End_Date])" from data type "DT_DBTIMESTAMP" to data type "DT_STR" failed with error code 0xC00470C5.

Evaluating function "SUBSTRING" failed with error code 0xC00470C4.

(Microsoft.DataTransformationServices.Controls)

------------------------------ BUTTONS:

OK

sql-server
string
date
ssis
expression
asked on Stack Overflow May 15, 2021 by insanity

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0