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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extracting text out of a string 1

Status
Not open for further replies.

Goosetown

Technical User
May 26, 2004
8
0
0
CA
Hello,
I have a field (normal range) that returns data like this:
1-10
11-20
21-50

and so on and so on. What I'd like to do is to be able to just pull out the value to the right of the '-' so that I'd be left with:
10
20
50

I have been playing with ExtractString but that isn't giving me what I need.

Any help or hints on this would be greatly appreciated.

Thanks!!!!
 
Try:

TrimLeft(Mid({Tablename.Fieldname},InStr({Tablename.Fieldname},'-')+1))
 
Hmmm, must be using an old version of Crystal, I should know by now to respond with oldest version syntax:

Mid({Tablename.Fieldname},InStr({Tablename.Fieldname},'-')+1)

Rudolph: Not sure why you had a TrimLeft in there, that wouldn't work.

-k
 
Thanks Guys!,
I used mrudolph's formula and it worked like a charm. I'm on V8.5.

Can't thank you guys enough for your help.

Goosetown.
 
Hey Synapse,

I included TrimLeft just in case there are instances where there are spaces after the '-'. It has just been my experience that data isn't always perfectly entered or formatted, so TrimLeft is just to catch those. For data values where there aren't any spaces after the '-' then TrimLeft doesn't hurt anything, it just has nothing to trim from the left since the first character would be a non-space in that instance.

May not always be necessary, but doesn't hurt either. :)
 
8.5 supports the Split function as well.

It looks odd, but it's quicker to type ;)

I'd misread the trimleft function, that should work fine, but it's not required as there aren't any spaces of the left.

-k
 
Goosetown,

If you are 100% certain at all times that in your field there will NEVER be spaces after the '-' for your range, then Synapse is correct in that the TrimLeft would not be required. Since this wasn't known from your post, that is why I included the TrimLeft (better safe than sorry!). Use or omit TrimLeft in the formula I posted at your discretion. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top