1
votes

I am using the following expression:

[TIMEPERIOD_ID]==1?"JANUARY":
[TIMEPERIOD_ID]==2?"FEBRUARY":
[TIMEPERIOD_ID]==3?"MARCH": 
[TIMEPERIOD_ID]==4?"APRIL":
[TIMEPERIOD_ID]==5?"MAY":
[TIMEPERIOD_ID]==6?"JUNE":
[TIMEPERIOD_ID]==7?"JULY":
[TIMEPERIOD_ID]==8?"AUGUST":
[TIMEPERIOD_ID]==9?"SEPTEMBER":
[TIMEPERIOD_ID]==10?"OCTOBER":
[TIMEPERIOD_ID]==11?"NOVEMBER":
[TIMEPERIOD_ID]==12?"DECEMBER"

And it throws the following exception:

ERROR - The data types "DT_WSTR" and "DT_I4" are incompatible for binary operator "==". The operand types could not be implicitly cast into compatible types for the operation. To perform this operation, one or both operands need to be explicitly cast with a cast operator.

Any suggestions?

1
The error tells you TIMEPERIOD_ID is an nvarchar, but you are comparing it to an int.GSerg
TIMPERIOD_ID IS UNICODE STRING OF LENGTH 50Tirtha Roy Chowdhury

1 Answers

3
votes

From the error mentioned, it looks like [TIMEPERIOD_ID] data type is DT_WSTR and it cannot be compared to integer values. Try the following expression:

[TIMEPERIOD_ID] == "1" ? "JANUARY" :
[TIMEPERIOD_ID] == "2" ? "FEBRUARY" :
[TIMEPERIOD_ID] == "3" ? "MARCH" : 
[TIMEPERIOD_ID] == "4" ? "APRIL" :
[TIMEPERIOD_ID] == "5" ? "MAY" :
[TIMEPERIOD_ID] == "6" ? "JUNE" :
[TIMEPERIOD_ID] == "7" ? "JULY" : 
[TIMEPERIOD_ID] == "8" ? "AUGUST" :
[TIMEPERIOD_ID] == "9" ? "SEPTEMBER" :
[TIMEPERIOD_ID] == "10" ? "OCTOBER" :
[TIMEPERIOD_ID] == "11" ? "NOVEMBER" :
[TIMEPERIOD_ID] == "12" ? "DECEMBER" : ""