Yasir ayub
Yasir ayub

Reputation: 41

Cannot convert Date in SSIS Expression builder

SSIS expresion builder I have cast error cancnot convert string to datetime

"SELECT *
  FROM table Where OperatingDayDate>='"+@[User::MaxOperatingDayDateTime]

ERROR : CANNOT CONVERT STRING TO DATETIME

MaxOperatingDayDateTime IS variable DATETIME in SSIS OperatingDayDate is type DATE

Upvotes: 1

Views: 255

Answers (1)

Hadi
Hadi

Reputation: 37313

You have to cast the variable data type:

"SELECT *
  FROM table Where OperatingDayDate>='"+  (DT_WSTR,50)@[User::MaxOperatingDayDateTime] + "'"

One thing not mentioned, if you are using the SQL command in OLEDB Source you can use parameterized query:

SELECT * FROM table Where OperatingDayDate >= ?

Upvotes: 1

Related Questions