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!

Eliminating the last character of a string

Status
Not open for further replies.

Hillary

Programmer
Feb 15, 2002
377
US
For some records in the database, last name field ends with ^. I want to trim this character off where it exists. I am using an If statement but how do I only trim the right most character? This is what I have so far...

If Right({CSL_STD_DEMO_DISTRICT.FIRST_NAME},1) = "^" then TrimRight({CSL_STD_DEMO_DISTRICT.FIRST_NAME},1) else
{CSL_STD_DEMO_DISTRICT.FIRST_NAME}

The TrimRight part of the statement is not correct.

Thanks for your help!

Hillary
 
This should do it:

if <<condition>> then left({YourString},Length({YourString})-1)


Software Sales, Training, Implementation and Support for Exact Macola, eSynergy, and Crystal Reports
dgilsdorf@trianglepartners.com
 
If instr({CSL_STD_DEMO_DISTRICT.FIRST_NAME},&quot;^&quot;) > 0 then mid({CSL_STD_DEMO_DISTRICT.FIRST_NAME},instr({CSL_STD_DEMO_DISTRICT.FIRST_NAME},&quot;^&quot;)-1) else
{CSL_STD_DEMO_DISTRICT.FIRST_NAME}

-k
 
If instr({CSL_STD_DEMO_DISTRICT.FIRST_NAME},&quot;^&quot;) > 0 then mid({CSL_STD_DEMO_DISTRICT.FIRST_NAME},instr({CSL_STD_DEMO_DISTRICT.FIRST_NAME},&quot;^&quot;)-1) else
{CSL_STD_DEMO_DISTRICT.FIRST_NAME}

Or you might just use the following instead:

Replace ({CSL_STD_DEMO_DISTRICT.FIRST_NAME}, &quot;^&quot;, &quot;&quot;)

-k
 
Thanks everyone. I used the Replace statment and it works great :)

Hillary
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top