removing extra characters from data

J

jay

Field alpha contains data which appears as follows:
04-24053-jf
03-12345

Q1. What is the syntax if any for an update query that
would remove the characters starting with the second dash
so that 04-24053-jf would now be 04-24053

Cousin question

Field beta contains data which appears as follows:
12345678
1234567
87654321-ab
7654321-bd

Q2. What is the syntax if any for an update query that
would remove the characters starting with the dash so
that the data would look like 87654321 or 7654321

I am familiar with using access 2000, but not familiar
with code or sql.
 
G

Guest

For Q1. if alpha length string must be of 8 characters
then try using the len() and Left$() functions

For Q2. if you always have a string of numbers (variable
length) and then the "-xx" at the end try the Val()
function.
 
J

John Spencer (MVP)

UPDATE For #1:

UPDATE YourTable
SET Alpha =
Left(Alpha,Instr(Instr(1,Alpha,"-"),Alpha,"-")-1)
WHERE Alpha Like "*-*-*"

UPDATE For #2
UPDATE YourTable
SET Beta =
Left(Beta,Instr(1,Beta,"-")-1)
WHERE Beta Like "*-*"
 

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

Top