1

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?

4

1 回答 1

3

[TIMEPERIOD_ID]从提到的错误来看,数据类型似乎是DT_WSTR并且不能与整数值进行比较。试试下面的表达式:

[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" : ""
于 2019-05-17T20:21:51.397 回答