Need to trim off last two characters on the right

For example - I have a sku called 1102301 and I need to return the value of 11023 without the 01.  Is there a way to do this in asp?  I tried using the rtrim but I keep getting errors.

Thanks!

foreverditaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

foreverditaAuthor Commented:
I should also add that the skus are all different lengths - example:

1102301
134202
154231109

(where I still need to trim the last two numbers from the end)

0
mantaraeCommented:
rtrim is to remove spaces.

you probably would want to use left

<% =Left("11023", len(yourSKU) - 2) %>

If you use right, you would only get the 2 numbers you're trying to get rid of.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
peh803Commented:
This is just an add on to mantarae's already great post, so please; give credit where credit is due (i.e., I'm NOT trying to steal anyone's points)!

I just wrote a function (today!) to do this for me....Take a look, you may find it useful.

Regards,
peh803

<%
function trimRightChars(sStr, lNumChars)
  Dim sRetStr
  sRetStr = left(sStr, (len(sStr)-lNumChars))
  trimLastChar = sRetStr
end function
%>

So, to trim off the right-most two characters, you'd do this:
<%
Dim sString
sString = "1234567890"
response.write "Untrimmed: " & sString & "<BR>"
response.write "trim 1: " & trimRightChars(sString,1) & "<BR>"
response.write "trim 2: " & trimRightChars(sString,2) & "<BR>"
response.write "trim 3: " & trimRightChars(sString,3) & "<BR>"
response.write "trim 4: " & trimRightChars(sString,4) & "<BR>"
%>

I think if you run this example, you'll see how it works!

Regards,
peh803
0
ColosseoCommented:
Hi

i'm not trying to steal anyones points either :)

but i think pehs function has a typo and should be

<%
function trimRightChars(sStr, lNumChars)
  Dim sRetStr
  sRetStr = left(sStr, (len(sStr)-lNumChars))
  trimRightChars= sRetStr
end function
%>

Cheers

Scott
0
peh803Commented:
yes scott, you're exactly right, thank you for that!

peh803
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.

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.