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!

Trim character and after character 1

Status
Not open for further replies.

tonyvee1973

IS-IT--Management
Oct 22, 2009
156
GB
Hi all

A simple one i hope but i have brain drain today...

I have a crystal report and need to do some trimming on a field, at present the data looks like:

302-276
302-1182
302-873

I need to trim the - and anything after that

Can anyone help?
Thanks as always
 
use the instr function.
It returns the postion number of the characters.
I believe the syntax is:

numbervar hyphen := instr({table.field],"-");
{table.field}[1 to hyphen-1]



Howard Hammerman,
Crystal Training and Crystal Material
On-site classes and one-on-one coaching
Low-cost telephone/email support
 
Hi and thanks for the reply
this seems to work but trims everything BEFORE the -
 
Sorry, ignore my previous reply.
I need to trim everything BEFORE the -

Thanks
 
Try this

numbervar hyphen := instr({table.field],"-");
{table.field}[hyphen+1 to 20]

Note: I am using 20 as a guess. Replace it with whatever your field length is.

Howard Hammerman,
Crystal Training and Crystal Material
On-site classes and one-on-one coaching
Low-cost telephone/email support
 
Hi and thanks
I managed to solve it quite easily in the end (Just had to put my brain in gear) :)

As i just needed to trim after the first 3 characters i used the below:

Mid({Table_field},5)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top