1

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

Hadi
  • 36,233
  • 13
  • 65
  • 124
Yasir ayub
  • 41
  • 4

1 Answers1

1

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 >= ?
Hadi
  • 36,233
  • 13
  • 65
  • 124