Need Mid Function

D

Dataman

I have a ClientSampID that looks like this: T2/LA-10-(0-6)

I am looking for a statement that will pull the text after the "/" and
before the first "-". Example: LA

There may be more than 2 characters after the "/" and before the first "-".
Example: T2/LAA-10-(0-6)

This statemant works if there are only 2 characters but fails if tthere are
more:

Left(Trim(Mid([ClientSampID],InStr(1,[ClientSampID],'/')+1,InStr(InStr(1,[ClientSampID],'-')+1,[ClientSampID],'-')-InStr(1,[ClientSampID],'-'))),InStr(1,Trim(Mid([ClientSampID],InStr(1,[ClientSampID],'/')+1,InStr(InStr(1,[ClientSampID],'-')+1,[ClientSampID],'-')-InStr(1,[ClientSampID],'-'))),'-')-1)Help would be appreciated.Thanks in advanceDC
 
K

KARL DEWEY

Try this --
Mid([ClientSampID],InStr(1,[ClientSampID],'/')+1,
InStr([ClientSampID],'-')-InStr(1,[ClientSampID],'/')-1)
 
F

fredg

I have a ClientSampID that looks like this: T2/LA-10-(0-6)

I am looking for a statement that will pull the text after the "/" and
before the first "-". Example: LA

There may be more than 2 characters after the "/" and before the first "-".
Example: T2/LAA-10-(0-6)

This statemant works if there are only 2 characters but fails if tthere are
more:

Left(Trim(Mid([ClientSampID],InStr(1,[ClientSampID],'/')+1,InStr(InStr(1,[ClientSampID],'-')+1,[ClientSampID],'-')-InStr(1,[ClientSampID],'-'))),InStr(1,Trim(Mid([ClientSampID],InStr(1,[ClientSampID],'/')+1,InStr(InStr(1,[ClientSampID],'-')+1,[ClientSampID],'-')-InStr(1,[ClientSampID],'-'))),'-')-1)Help would be appreciated.Thanks in advanceDC

So you wish to get LA or LAA from your examples?

NewColumn:Mid([ClientSampID],InStr([ClientSampID],"/")+1,(InStr([ClientSampID],"-")-1)-InStr([ClientSampID],"/"))

The above expression should be all on one line.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top