Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Substr

Status
Not open for further replies.

cranebill

IS-IT--Management
Jan 4, 2002
1,113
US
I have the following function:

substr(MSG_TEST_X,1,index(MSG_TEST_X,'-') - 2)

If I change the "- 2" to "+ 2" it works, it just does not seem to work with subtracting. I have also tried the position function and the same result happens.

How can i get this to work subtracting 2 positions from where the "-" is found?

Any help appreciated.
 
Just out of curiosity, what position is the "-" in? Is it possible that -2 results in a value less than 1?
 
Just thinking through this a little more - I wonder if you have any values where the "-" is not found. In that case, perhaps the end value of the index is 0 and 0 - 2 wouldn't work, but 0 + 2 would. I don't have anything to test it on though so I'm just throwing that out there.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top