First question here :)
I'm working on a project where i need to copy only 3 columns from Employee table (ID, Firstname, Lastname) from DB to an Excel worksheet destination,
and i need to create new column that will be called "Seniority".
I was thinking to take the "HireDate" (I've thought to map it also for the derived column transformation) of all employees and transform it to years of seniority.
In the Derived Column Transformation Editor i put these values:
Derived column name - Seniority
Derived column -
Expression - (DT_I4) DATEDIFF( "YEAR", YEAR( [HireDate] ) , YEAR( GETDATE() ) )
and got this error:
Error at Data Flow Task [Derived Column [234]]: The function
"DATEDIFF" does not support the data type "DT_I4" for parameter number
2. The type of the parameter could not be implicitly cast into a compatible type for the function. To perform this operation, the
operand needs to be explicitly cast with a cast operator.
Error at Data Flow Task [Derived Column [234]]: Evaluating function
"DATEDIFF" failed with error code 0xC0047089.
Error at Data Flow Task [Derived Column [234]]: The function
"DATEDIFF" does not support the data type "DT_I4" for parameter number
2. The type of the parameter could not be implicitly cast into a compatible type for the function. To perform this operation, the
operand needs to be explicitly cast with a cast operator.
Error at Data Flow Task [Derived Column [234]]: Computing the
expression "(DT_I4) DATEDIFF( "YEAR", YEAR( [HireDate] ) , YEAR(
GETDATE() ) )" failed with error code 0xC00470C5. The expression may
have errors, such as divide by zero, that cannot be detected at parse
time, or there may be an out-of-memory error.
Error at Data Flow Task [Derived Column [234]]: The expression
"(DT_I4) DATEDIFF( "YEAR", YEAR( [HireDate] ) , YEAR( GETDATE() )
)" on "Derived Column.Outputs[Derived Column
Output].Columns[Seniority]" is not valid.
Error at Data Flow Task [Derived Column [234]]: Failed to set property
"Expression" on "Derived Column.Outputs[Derived Column
Output].Columns[Seniority]".
(Microsoft Visual Studio)
Please help.
Thanks,