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

Formula to remove text after 1

Status
Not open for further replies.

viperstorm

Technical User
Aug 14, 2008
4
US
My Data looks like this:
Department - Location

I would like to display Department and remove everything after the first space and dash. So I need to remove everything after " - ".
Hope you can help.
 
extractstring({string.field},'',' -')

Please include version info with post as different versions have different methods for solving.

'J
 
I just re-read your post and I am a little confused as to which text you wish to have displayed.

//Source text
Department - Location

//Result required:

//'Department'

extractstring({string.field},'',' -')

//'Department -'

extractstring({string.field},'',mid({string.field},instr({string.field},'- ')+1))

//'Department - '

extractstring({string.field},'',mid({string.field},instr({string.field},'- ')+2))


Hope that helps to clarify.

'J
 
mid({string.field},instr({string.field},' - ')+1)

...would be sufficient for spaces before and after a hyphen, but I'm confused too about where the spaces are--before AND after the hyphen? before? after?

-LB
 
Sorry, I misunderstood. But you haven't clarified where the space is. If there is always a space before the hyphen, then just use:

left({table.string}, instr({table.string}," ")-1)

-LB
 
Data Displayed:
Department - Location

Data Wanted:
Department

I need to remove the space dash space & all text after.

Thanks for your help CR85USER & lbass!
I wouldnt of figured it out without you. You Rule.

This finally worked for me. In case anyone else needs it.

left({tblCases.To}, instr({tblCases.To}," - ")-1)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top