简体   繁体   中英

IBM Cognos IF/casewhen + _days_between

I have a liste of value and when a value = something i want it to calcultate a number of day between 2 dates. Error: "QE-DEF-0459 CCLException Incompatible data types in CASE statements"

Exemple: CASE WHEN ([Statut dossier] = 'Att 1 sv') THEN (_days_between (current_date;[Date start])) ELSE (0) END

I tried with IF, something like that: IF ([Statut dossier] = 'Att 1 sv') THEN (_days_between (current_date;[Date start]) ELSE ('0')

Since the error message mentions data types your first investigation should be of the data types of the things in the expression and the expression itself.

You will notice that you want a value of the days between two dates to be returned if your Statut dossier = 'Att 1 sv' but you want a string if isn't. Days between returns an integer, which is not compatible with strings.

So assuming that you want numeric values you would need to remove the ('0') and substitute (0). Assuming you want the result of the expression to be strings then you would need to cast the result of the days between expression to make it compatible with the else result. I'm guessing you want the former rather than the latter.

You will need to verify the usage of the expression as well, once you've gotten past this hurdle. You would need to determine if this is a measure or an attribute.

Guessing, you may need to wrap the [Start Date] in a cast.

CASE WHEN ([Statut dossier] = 'Att 1 sv') THEN (_days_between (current_date;cast([Date start];date))) ELSE (0) END

Also watch the single quotes '0' is a string 0 is a number

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM