COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: jd on 21 Dec 2009 12:56:40 PM

Title: how the substring function will work
Post by: jd on 21 Dec 2009 12:56:40 PM

I am confused how the substring function will work what will be the output for below syntex;

Year/Month = substring(?p_yearmonth?, 3, 4)+ substring(?p_yearmonth?, 8, 2)
Title: Re: how the substring function will work
Post by: angela on 21 Dec 2009 04:16:20 PM
Substring takes a value (in your case a parameter) and returns certain characters for a certain length.

Year/Month = substring(?p_yearmonth?, 3, 4)+ substring(?p_yearmonth?, 8, 2)

Your filter says:
[The Year/Month data item] = the third position of the parameter chosen for 4 characters + the eigth position of the chosen parameter for 2 characters.

But I can't think of any parameter value a person would pick that would result in at least 9 digits.

Here's a more common one assuming the parameter the person picks is '2009-10':
Year/Month = substring(?p_yearmonth?, 1, 4)+ substring(?p_yearmonth?, 6, 2)

Another problem you might have is that it might think it should ADD instead of CONCATENATE.  If that happens you'll need to cast the parts as character instead of integer which wants to do math.