• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 538
  • Last Modified:

Extract part of a text field in access

I have a field that has data that looks like this  abb-123-dev,3 and I want to remove the ,3 from the result.  All the data will have a ,xxx   Is there anyway to remove the , and everything to the right of the comma in an access query?
0
sannunzi
Asked:
sannunzi
1 Solution
 
vguzmanIT ManagerCommented:
Right ("Your string", 2)
that would take the 2 characters from it
0
 
Dale FyeCommented:
SELECT [yourfield], iif(instr([yourfield]&"", ",") = 0, [yourfield], LEFT([yourField], instr([yourField], ",") - 1)) as Modified
FROM yourtable

This takes into account the possibility that some records could be NULL, or not have the ",xxx" format
0
 
mbizupCommented:
left(s, instr(1,s,",") -1)
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
peter57rCommented:
bityouwant = split(fieldname, ",")(0)

This assumes there is no other comma in the string.
0
 
Jeffrey CoachmanMIS LiasonCommented:
<No Points wanted>

As you want to "Remove" this data, you might also consider simply "Splitting" the field in two instead.

This way you can either eliminate the main field altogether and simply concatenate that two parts for display purposes.
This way you will have both "Parts" of the string available individually.

You can modify any of the previous Experts posts to do this, or try something like this:

SELECT YourTable.YourString, Left([Yourstring],InStr([Yourstring],",")-1) AS YourStringPrefix, Right([Yourstring],Len([Yourstring])-InStr([Yourstring],",")+1) AS YourstringSuffix
FROM YourTable;


As I stated, no points wanted, just another thing to consider...
(Just an FYI)

;-)

Jeff


0
 
sannunziAuthor Commented:
worked like a champ!  Thanks so much.  Saved me hours of work
0
 
Dale FyeCommented:
glad to help
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now