Author Topic: how the substring function will work  (Read 363 times)

Offline d.laxmi

  • Community Leader
  • *****
  • Posts: 201
  • Forum Citizenship: +0/-0
how the substring function will work
« on: 21 Dec 2009 11:56:40 am »

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)

Offline angela

  • Senior Member
  • ****
  • Posts: 64
  • Forum Citizenship: +4/-0
Re: how the substring function will work
« Reply #1 on: 21 Dec 2009 03: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.