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!

pulling substring from a field containing a comma 1

Status
Not open for further replies.

maynard444

Programmer
Jul 1, 2003
13
0
0
US
All right, here is my question: I am trying to pull a string from a field that contains a comma. This is an employee name field, and all I want to pull out of it is the last name of the employee. So if the record contained:

Smith, Bob

I would only want to pull the substring before the comma.
If anybody has done this or has any information let me know. Thanks
maynard
 
Or:

left({table.field}, instr({table.field},",")-1)

or the fastest would be to use the database to do the work using a SQL Expression, but since you didn't share your database type and version, I can't construct it for you.

Ido's tidy little solution creates an array out of the field and then demonstrates the first element of the array, the above returns everything to the left of the comma, and might have a slight performance gain.

-k
 
Thanks for the help,it's exactly what i needed.
maynard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top