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

Extract data in between parentheses 1

Status
Not open for further replies.

Terpsfan

Programmer
Dec 8, 2000
954
US
I have a text field where I have data in between parentheses, like (TIPS) I would like to just extract the data from the parentheses. Does anyone have an example of how this works? I'm assuming you use a combination of mid and instr, but not sure how. Thanks
 
Code:
SELECT mid(textField, indexOf(textField,"("), indexOf(textField, ")") - indexOf(textField,"(")) FROM myTable


Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook

zen.gif

 
Mid([Field name],InStr([Field name],"(")+1,InStr([Field name],")")-InStr([Field name],"(")-1)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks for your Responses.

What I ended up doing was this, because the field always begins with a parentheses:

Mid$([FieldName],2,(Instr(2,[FieldName],")")-2))
 
Thanks PHV, your solution was actually better, because it parses out the string wherever the parentheses are in the field.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top