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!

Hyphenated Last Name - Remove hypen and left 3

Status
Not open for further replies.

NewToThis2

Technical User
Mar 30, 2004
62
US
CRV10 - I'm not sure if this is possible, but if it is, you guys will know! I have a LAST_NAME field that may include hyphenated last names, such as Olsen-Wright. I need to remove everything in front of Wright and have the result for the field be "Wright". Not sure how to do this since the number of characters to the left will not always be the same. Maybe I'm making this way too difficult. Any assistance would be most appreciated. Thanks!
 
Hi, Use a combination of the Instr and string array functions and length:

{LAST_NAME[Instr({LAST_NAME},'-')+ 1 to Length({LAST_NAME)]


should work, but test for the '-' first:

Code:
(If Instr({LAST_NAME},'-') <> 0 then
{LAST_NAME}[Instr({LAST_NAME},'-')+ 1 to Length({LAST_NAME}]
else
If Instr({LAST_NAME},'-') = 0 
then
{LAST_NAME})


Hope it helps..

[profile]


 
An alternative could be;

Code:
If Instr({LAST_NAME}, "-") <> 0 then
  Split({LAST_NAME}, "-") [2]  //returns all after the hyphen
else
  {LAST_NAME}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top