• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Trim Last Three Characters Off?

Guest
Apr 16, 2009 Apr 16, 2009

Copy link to clipboard

Copied

405-FW

438-FG

I have a case where I need to to trim the last three characters off

<%= RTrim(rsRecordset.Fields.Item("Column"), -3 .Value)%>

I tried the above but it did not like this.

Any ideas?

TOPICS
Server side applications

Views

1.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Apr 16, 2009 Apr 16, 2009

Copy link to clipboard

Copied

Are you looking to trim last three characters out of six every time or does prefix character length vary? It should be easy to force three character display using scripting which will effectively trim the last three off... I can google a code for you if you are having trouble finding something yourself.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 17, 2009 Apr 17, 2009

Copy link to clipboard

Copied

Every string in the results will need to have exactly 3 characters taken off so it's really quite straight forward.

I've tried google myself but have not found anything that works.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 17, 2009 Apr 17, 2009

Copy link to clipboard

Copied

It's a million years since I last used VBScript, but RTrim removes spaces from the end of a string.

If you want to remove the last three characters, you could do it this way:

  • Use Right(string, 3) to get the last three characters
  • Use Replace to replace the last three characters with an empty string

There might be a more elegant way to do it, but my recollection of VBScript was that "elegant" wasn't part of its vocabulary.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 17, 2009 Apr 17, 2009

Copy link to clipboard

Copied

<%= Right(rsRecordsetName.Fields.Item("ColName", 3).Value)%>

Of course this didn't work.

I've tried  variations on this but I can't get any to work.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 17, 2009 Apr 17, 2009

Copy link to clipboard

Copied

Wish I could help more. It's phenomenally simple in PHP:

substr($value, 0, -3);

Maybe time to come over to the sunny side of the street?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 20, 2009 Apr 20, 2009

Copy link to clipboard

Copied

David,


I've started building new stuff in PHP but for work, it's all ASP and I'm not ready to rebuild the store in PHP yet.

I wish I could just leave ASP behind but I'm forced to keep it going.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 17, 2009 Apr 17, 2009

Copy link to clipboard

Copied

Hi,

<%= RTrim(rsRecordsetName.Fields.Item.Value), 3 %>

Try this, It's been awhile since I asp'd

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 20, 2009 Apr 20, 2009

Copy link to clipboard

Copied

LATEST

I've tried that. Didn't work. Thanks

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines