G
Guest
how do I extract part of a field after the "/" character in a query?
Ted Allen said:Unless your fields are fixed length, and the "/" is always in the same spot,
you will likely also need the len() and instr() functions. Such as:
Right([YourField],len([YourField])-instr([YourField],"/",1))
Jamie Collins said:Ted Allen said:Unless your fields are fixed length, and the "/" is always in the same spot,
you will likely also need the len() and instr() functions. Such as:
Right([YourField],len([YourField])-instr([YourField],"/",1))
You could use just MID and INSTR e.g.
MID(MyTextCol,INSTR(1,MyTextCol,'/',1)+1)
Note the '1' used as the first argument to the INSTR function. Without
this your expression would error outside of the MS Access UI.
Jamie.
Ted Allen said:You're right Jamie, much cleaner solution. I forgot that the mid function
defaults the length to the remainder of the string if ommitted. Also, good
point about the start pos in the Instr() function. I guess I only use it in
Access environment so I hadn't come across that issue.
-Ted Allen
Jamie Collins said:Ted Allen said:Unless your fields are fixed length, and the "/" is always in the same spot,
you will likely also need the len() and instr() functions. Such as:
Right([YourField],len([YourField])-instr([YourField],"/",1))
You could use just MID and INSTR e.g.
MID(MyTextCol,INSTR(1,MyTextCol,'/',1)+1)
Note the '1' used as the first argument to the INSTR function. Without
this your expression would error outside of the MS Access UI.
Jamie.
Mary said:Hello, I used Jamie's solution successfully, however, I'm wondering if
there's a way to extract between to characters. The data I want to
extract
will always fall between "-" and ":". Right now I'm picking up everything
after "-".
Thanks,
Mary
Ted Allen said:You're right Jamie, much cleaner solution. I forgot that the mid
function
defaults the length to the remainder of the string if ommitted. Also,
good
point about the start pos in the Instr() function. I guess I only use it
in
Access environment so I hadn't come across that issue.
-Ted Allen
Jamie Collins said:Unless your fields are fixed length, and the "/" is always in the
same spot,
you will likely also need the len() and instr() functions. Such as:
Right([YourField],len([YourField])-instr([YourField],"/",1))
You could use just MID and INSTR e.g.
MID(MyTextCol,INSTR(1,MyTextCol,'/',1)+1)
Note the '1' used as the first argument to the INSTR function. Without
this your expression would error outside of the MS Access UI.
Jamie.
Ken Snell said:Something like this, perhaps:
ExtractedString = Mid(Left(OriginalString, InStrRev(OriginalString, ":") -
1), InStr(OriginalString, "-") + 1)
--
Ken Snell
<MS ACCESS MVP>
Mary said:Hello, I used Jamie's solution successfully, however, I'm wondering if
there's a way to extract between to characters. The data I want to
extract
will always fall between "-" and ":". Right now I'm picking up everything
after "-".
Thanks,
Mary
Ted Allen said:You're right Jamie, much cleaner solution. I forgot that the mid
function
defaults the length to the remainder of the string if ommitted. Also,
good
point about the start pos in the Instr() function. I guess I only use it
in
Access environment so I hadn't come across that issue.
-Ted Allen
:
Unless your fields are fixed length, and the "/" is always in the
same spot,
you will likely also need the len() and instr() functions. Such as:
Right([YourField],len([YourField])-instr([YourField],"/",1))
You could use just MID and INSTR e.g.
MID(MyTextCol,INSTR(1,MyTextCol,'/',1)+1)
Note the '1' used as the first argument to the INSTR function. Without
this your expression would error outside of the MS Access UI.
Jamie.
Mary said:Ken, I'm getting an "Undefined function, InStrRev" error, this is what I
tried:
DESCRIPTION:
Mid(Left([DESCR],InStrRev([DESCR],":")-1),InStr([DESCR],"-")+1)
Thanks, Mary
Ken Snell said:Something like this, perhaps:
ExtractedString = Mid(Left(OriginalString, InStrRev(OriginalString,
":") -
1), InStr(OriginalString, "-") + 1)
--
Ken Snell
<MS ACCESS MVP>
Mary said:Hello, I used Jamie's solution successfully, however, I'm wondering if
there's a way to extract between to characters. The data I want to
extract
will always fall between "-" and ":". Right now I'm picking up
everything
after "-".
Thanks,
Mary
:
You're right Jamie, much cleaner solution. I forgot that the mid
function
defaults the length to the remainder of the string if ommitted. Also,
good
point about the start pos in the Instr() function. I guess I only use
it
in
Access environment so I hadn't come across that issue.
-Ted Allen
:
Unless your fields are fixed length, and the "/" is always in the
same spot,
you will likely also need the len() and instr() functions. Such
as:
Right([YourField],len([YourField])-instr([YourField],"/",1))
You could use just MID and INSTR e.g.
MID(MyTextCol,INSTR(1,MyTextCol,'/',1)+1)
Note the '1' used as the first argument to the INSTR function.
Without
this your expression would error outside of the MS Access UI.
Jamie.
Ken Snell said:Which version of ACCESS are you using?
--
Ken Snell
<MS ACCESS MVP>
Mary said:Ken, I'm getting an "Undefined function, InStrRev" error, this is what I
tried:
DESCRIPTION:
Mid(Left([DESCR],InStrRev([DESCR],":")-1),InStr([DESCR],"-")+1)
Thanks, Mary
Ken Snell said:Something like this, perhaps:
ExtractedString = Mid(Left(OriginalString, InStrRev(OriginalString,
":") -
1), InStr(OriginalString, "-") + 1)
--
Ken Snell
<MS ACCESS MVP>
Hello, I used Jamie's solution successfully, however, I'm wondering if
there's a way to extract between to characters. The data I want to
extract
will always fall between "-" and ":". Right now I'm picking up
everything
after "-".
Thanks,
Mary
:
You're right Jamie, much cleaner solution. I forgot that the mid
function
defaults the length to the remainder of the string if ommitted. Also,
good
point about the start pos in the Instr() function. I guess I only use
it
in
Access environment so I hadn't come across that issue.
-Ted Allen
:
Unless your fields are fixed length, and the "/" is always in the
same spot,
you will likely also need the len() and instr() functions. Such
as:
Right([YourField],len([YourField])-instr([YourField],"/",1))
You could use just MID and INSTR e.g.
MID(MyTextCol,INSTR(1,MyTextCol,'/',1)+1)
Note the '1' used as the first argument to the INSTR function.
Without
this your expression would error outside of the MS Access UI.
Jamie.
Mary said:Access 97
Ken Snell said:Which version of ACCESS are you using?
--
Ken Snell
<MS ACCESS MVP>
Mary said:Ken, I'm getting an "Undefined function, InStrRev" error, this is what
I
tried:
DESCRIPTION:
Mid(Left([DESCR],InStrRev([DESCR],":")-1),InStr([DESCR],"-")+1)
Thanks, Mary
:
Something like this, perhaps:
ExtractedString = Mid(Left(OriginalString, InStrRev(OriginalString,
":") -
1), InStr(OriginalString, "-") + 1)
--
Ken Snell
<MS ACCESS MVP>
Hello, I used Jamie's solution successfully, however, I'm wondering
if
there's a way to extract between to characters. The data I want to
extract
will always fall between "-" and ":". Right now I'm picking up
everything
after "-".
Thanks,
Mary
:
You're right Jamie, much cleaner solution. I forgot that the mid
function
defaults the length to the remainder of the string if ommitted.
Also,
good
point about the start pos in the Instr() function. I guess I only
use
it
in
Access environment so I hadn't come across that issue.
-Ted Allen
:
Unless your fields are fixed length, and the "/" is always in
the
same spot,
you will likely also need the len() and instr() functions.
Such
as:
Right([YourField],len([YourField])-instr([YourField],"/",1))
You could use just MID and INSTR e.g.
MID(MyTextCol,INSTR(1,MyTextCol,'/',1)+1)
Note the '1' used as the first argument to the INSTR function.
Without
this your expression would error outside of the MS Access UI.
Jamie.
Ken Snell said:ahhh......ACCESS 97 doesn't contain that built-in function. So let's change
the expression, assuming that there is only the one : character in the
string:
ExtractedString = Mid(Left(OriginalString, InStr(OriginalString, ":") - 1),
InStr(OriginalString, "-") + 1)
--
Ken Snell
<MS ACCESS MVP>
Mary said:Access 97
Ken Snell said:Which version of ACCESS are you using?
--
Ken Snell
<MS ACCESS MVP>
Ken, I'm getting an "Undefined function, InStrRev" error, this is what
I
tried:
DESCRIPTION:
Mid(Left([DESCR],InStrRev([DESCR],":")-1),InStr([DESCR],"-")+1)
Thanks, Mary
:
Something like this, perhaps:
ExtractedString = Mid(Left(OriginalString, InStrRev(OriginalString,
":") -
1), InStr(OriginalString, "-") + 1)
--
Ken Snell
<MS ACCESS MVP>
Hello, I used Jamie's solution successfully, however, I'm wondering
if
there's a way to extract between to characters. The data I want to
extract
will always fall between "-" and ":". Right now I'm picking up
everything
after "-".
Thanks,
Mary
:
You're right Jamie, much cleaner solution. I forgot that the mid
function
defaults the length to the remainder of the string if ommitted.
Also,
good
point about the start pos in the Instr() function. I guess I only
use
it
in
Access environment so I hadn't come across that issue.
-Ted Allen
:
Unless your fields are fixed length, and the "/" is always in
the
same spot,
you will likely also need the len() and instr() functions.
Such
as:
Right([YourField],len([YourField])-instr([YourField],"/",1))
You could use just MID and INSTR e.g.
MID(MyTextCol,INSTR(1,MyTextCol,'/',1)+1)
Note the '1' used as the first argument to the INSTR function.
Without
this your expression would error outside of the MS Access UI.
Jamie.
Mary said:Hello, can I ask for one more variation? I'd like to pull the 3rd
character
after the /. I'm getting the 3rd character plus everything that follows.
I
only need that character.
Here's what I've got.
Special: Mid([Circuit_ID],InStr(3,[Circuit_ID],'/',3)+3)
How do I cut it off so nothing else displays but the 3rd character after
the
/.
Thanks!
Mary
Ken Snell said:You're welcome.
Ken Snell said:ahhh......ACCESS 97 doesn't contain that built-in function. So let's change
the expression, assuming that there is only the one : character in the
string:
ExtractedString = Mid(Left(OriginalString, InStr(OriginalString, ":") - 1),
InStr(OriginalString, "-") + 1)
--
Ken Snell
<MS ACCESS MVP>
Mary said:Access 97
Ken Snell said:Which version of ACCESS are you using?
--
Ken Snell
<MS ACCESS MVP>
Ken, I'm getting an "Undefined function, InStrRev" error, this is what
I
tried:
DESCRIPTION:
Mid(Left([DESCR],InStrRev([DESCR],":")-1),InStr([DESCR],"-")+1)
Thanks, Mary
:
Something like this, perhaps:
ExtractedString = Mid(Left(OriginalString, InStrRev(OriginalString,
":") -
1), InStr(OriginalString, "-") + 1)
--
Ken Snell
<MS ACCESS MVP>
Hello, I used Jamie's solution successfully, however, I'm wondering
if
there's a way to extract between to characters. The data I want to
extract
will always fall between "-" and ":". Right now I'm picking up
everything
after "-".
Thanks,
Mary
:
You're right Jamie, much cleaner solution. I forgot that the mid
function
defaults the length to the remainder of the string if ommitted.
Also,
good
point about the start pos in the Instr() function. I guess I only
use
it
in
Access environment so I hadn't come across that issue.
-Ted Allen
:
Unless your fields are fixed length, and the "/" is always in
the
same spot,
you will likely also need the len() and instr() functions.
Such
as:
Right([YourField],len([YourField])-instr([YourField],"/",1))
You could use just MID and INSTR e.g.
MID(MyTextCol,INSTR(1,MyTextCol,'/',1)+1)
Note the '1' used as the first argument to the INSTR function.
Without
this your expression would error outside of the MS Access UI.
Jamie.
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.