Type Cast Error

Ali Ahad 131 Reputation points
2025-04-08T22:07:29.25+00:00

I am trying to write a derived column expression to check for year. We get a data file for employees for previous month in the current month and I am trying to tackle the year so when I get the file in January the year should be 2024 since I will get the data for December, but I am getting conversion error:

Screenshot 2025-04-08 170459

my expression code

(DT_WSTR, 4) MONTH( GETDATE()  )  == 1 ?
DATEADD("YEAR",-1,GETDATE()) :
DATEADD("YEAR",0 ,GETDATE())


Any help is appreciated.

SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,681 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.