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

Help With String Formula 1

Status
Not open for further replies.

goduke

IS-IT--Management
Feb 13, 2006
65
US
Hello,

I need help with a string formula. What I have is a string that is a combo of First Name, Last Name Initial, a dash, and then the company name. What I need is the dash, to the end removed.

Example of Data:
Kraft, D - Other
Fabrie J-Intel 3
Lindberg H-Unix-2-Tech Solutions

Results Needed:
Kraft, D
Fabrie J
Lindberg H

Some problems that you may run into is that sometimes there is a space between the last name initial and the dash, and sometimes there isnt. Also, there may be more than one dash, but I just want the first dash and over removed. Or I guess you could say the first character after the last name initial and over removed. Any help would be great. Thanks.
 
this should give you everything to the left of the 1st "-".

{@beforedash}
whileprintingrecords;
stringvar sv := {@YourFormulaName};
numbervar is := instr(sv,"-");
stringvar sr := left(sv,is-1);
sr
 
Fisheromacse,

This is exactly what I asked for, however, I have been looking through my data, and I think I need to change it up. What I need to do, is just show the last name. So that would be anything after the first space, to the end, taken off. (there are some commas after the first name that are giving me trouble)

Example Data:
Kraft, D - Other
Fabrie J-Intel 3
Lindberg H-Unix-2-Tech Solutions

Results Needed:
Kraft
Fabrie
Lindberg

Thanks again for your help!
 
use the same basic formula and change the "-" to " ", as below:

{@beforespace}
whileprintingrecords;
stringvar sv := {@YourFormulaName};
numbervar is := instr(sv," ");
stringvar sr := left(sv,is-1);
sr
 
Thanks Fisheromacse - that worked perfect!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top