Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Help with Substr

Help with Substr

Help with Substr

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.

RE: Help with Substr

Just out of curiosity, what position is the "-" in? Is it possible that -2 results in a value less than 1?

RE: Help with Substr

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close