COGNOiSe.com - The IBM Cognos Community

IBM Cognos 8 Platform => COGNOS 8 => Report Studio => Topic started by: wbarry123 on 06 Jun 2011 09:47:53 AM

Title: substring issue
Post by: wbarry123 on 06 Jun 2011 09:47:53 AM
I have the following string format and need to return 12345.  The length can be 123 or 123456 so I am assuming I need to key off of the "-".
xxx_sssss-aaaa.bb.cc-12345-01

Any ideas?

I am using SQL server and version 8.4.1
Thank you in advance.
Title: Re: substring issue
Post by: rockytopmark on 06 Jun 2011 11:30:24 AM
Your value has multiple "-" occurrences, so you will need to add on to this, but the gist of what you need involves adding the Position() function to locate the "-" characters.  My guess is you will need to keep widdling down the string until you get the desired value.

substring([data Item],position('-',[Data Item]),6)

This is a Cognos 8 generic function, but there may be something in the SQL Server function list (inStr?) that might be more flexible.

HTH.... M

Title: Re: substring issue
Post by: PRIT AMRIT on 06 Jun 2011 10:05:57 PM
http://www.cognoise.com/community/index.php/topic,14343.0.html (http://www.cognoise.com/community/index.php/topic,14343.0.html)