trim commands

S

steve

I want to pull the right 4 characters from a field
named "alpha". This field contains data of various
lengths. The field has one of the following in the last 4
digits:

" ABC"
" BCD"
" CDE"
"DEFG"

If I use the "right" command "=right(alpha,4)", I get the
output as shown above. What I want is below (eliminating
the space in the first character of the first three
records:

"ABC"
"BCD"
"CDE"
"DEFG"

What function does this?

Also, when working with a field that has data of various
lengths, what function would pull back the 4th character,
counting from the right back to the left
(ie, "abcdefghij", and I want to pull back just the "g")?

Thanks.
 
G

George Nicholson

To remove leading or trailing spaces: Trim(right(alpha,4))

To get the 4th from last character: Mid(alpha,len(alpha)-3,1)

i.e., Mid(StringToExtractFrom, StartingCharacterPosition,
NumberOfCharactersToReturn)
 
S

steve

Perfect -- thanks for the quick reply.
-----Original Message-----
To remove leading or trailing spaces: Trim(right(alpha,4))

To get the 4th from last character: Mid(alpha,len(alpha)- 3,1)

i.e., Mid(StringToExtractFrom, StartingCharacterPosition,
NumberOfCharactersToReturn)
--
George Nicholson

Remove 'Junk' from return address.




.
 

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