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

Passing a second parameter to LTRIM

Status
Not open for further replies.

benshsms

IS-IT--Management
Mar 3, 2004
8
GB
Essentially I want to write the SQL function

LTRIM (JOBTITLE, '-')

to remove anything before the hypen from the text field job title. however crystal's version of LTRIM wont allow me to pass the second parameter ('-'),or any other second parameter, into the function. Does anyone know of a formula that can be used as a work around to this problem

Cheers!
 
Try this:
Code:
If Instr(JOBTITLE, '-') > 0 then
  Mid(JOBTITLE, (Instr(JOBTITLE, '-') + 1)
else
  JOBTITLE
-D
 
Thanks it works superbly...is there any similar code I could insert to delete to the RIGHT of the hypen?
 
Thie will get you everything to the left of the hyphen:
Code:
If Instr(JOBTITLE, '-') > 0 then
  Left(JOBTITLE, Instr(JOBTITLE, '-')-1)
else
  JOBTITLE

~Brian
 
To delete to the right of the hyphen, try this:
Code:
If Instr(JOBTITLE, '-') > 0 then
  Left(JOBTITLE, (Instr(JOBTITLE, '-') - 1))
else
  JOBTITLE

-D
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top