COGNOiSe.com - The IBM Cognos Community

IBM Cognos 10 Platform => Cognos 10 BI => Report Studio => Topic started by: neverping on 10 Oct 2013 07:47:27 AM

Title: What is wrong in this Expression?
Post by: neverping on 10 Oct 2013 07:47:27 AM
Hi guys,

i am facing an error on function below. This function works fine, but when need validate the report cames with erros and my cliente said this is problem to acceppt.

Follow the expression.

substring(substring(timestamp2string(_add_years (date2timestamp(AsOfDate ());-1));3;4);1;2)
+ 'A'
Returns 12 A ( current year + letter A)

There is another awaya to return this on Cognos..based Oracle database.


Thanks. :D
Title: Re: What is wrong in this Expression?
Post by: Lynn on 10 Oct 2013 08:10:44 AM
The syntax you are showing is for a layout calculation rather than a query calculation. Not sure if that is your intention or not, but the correct syntax would use commas instead of semi-colons and strings enclosed in double quotes rather than single quotes


substring(substring(timestamp2string(_add_years (date2timestamp(AsOfDate ()),-1)),3,4),1,2) + "A"


If you need a database calculation, this is an equivalent expression:


substring ( cast( extract(year, _add_years( current_date,-1) ), CHAR(4) ), 3, 4 ) + 'A'