derived col trans support

San 121 Reputation points
2020-12-12T13:17:12.857+00:00

Hi Experts,

I am facing issue with derived col transformation.

In the pic attached below are the formula
People Aged Above 18: (DT_I4)DATEDIFF("Minute",(DT_DATE)Patient_In,(DT_DATE)Patient_Out)
Appointment > 500 minutes are defaulted to 60 minutes: (DT_STR,50,1252)[People Aged Above 18].Mins > "500" ? "60" : (DT_STR,50,1252)[People Aged Above 18].Mins

I am taking the datediff and checking if diff mins are > 500 then covert into 60 mins else keep the difference. but some of the data is also converting. eg are attached in pic

47603-d2.jpg

47651-d1.jpg

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

Accepted answer
  1. Dan Guzman 9,236 Reputation points
    2020-12-12T17:50:24.507+00:00

    This is because you are comparing data as strings instead of integers. You can simply omit the type casts and specify integer literals if the data type is DT_I4 as the first expression suggests:

    [People Aged Above 18].Mins > 500 ? 60 : [People Aged Above 18].Mins
    

    If you want a string result, add a type cast of the result back to string:

    (DT_STR,50,1252))([People Aged Above 18].Mins > 500 ? 60 : [People Aged Above 18].Mins)
    

0 additional answers

Sort by: Most helpful

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.