Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

[b]Removing character from end of string[/b] 1

Status
Not open for further replies.

Designware

Technical User
Sep 24, 2002
202
Hi,

I need to remove the dash IF they appear at the end of a db field and put the result into a Formula Field.

db_field Formula_Field
01-2345- 01-2345
02-7503 02-7503
72-23089- 72-23089
93-45345 93-45345

I think I can use something like:

IF (RIGHT({db_field},1))="-" Then ???????


What can I put in the ????? area so the formula field ends up with the data listed above?

Thanks for your help.

Dale
 
Designware,

The following formula should return what you seek.
{@FormulaField}
Code:
[blue]IF RIGHT[/blue]({Table.Field},1)="-" [blue]THEN LEFT[/blue]({Table.Field},[blue]LENGTH[/blue]({Table.Field})-1) [blue]ELSE[/blue] {Table.Field}

This formula will return the field without the final "-" when present, and the original field when the last character is not "-".

Cheers!

Mike
---------------------------------------------------------------
"To be alive is to revel in the moments, in the sunrise and the sunset, in the sudden and brief episodes of love and adventure,
in the hours of companionship. It is, most of all, to never be paralyzed by your fears of a future that no one can foretell."
 
PS: You may wish to wrap all your functions in the "Trim" function to ensure no empty spaces in the string. for example: "123-456- " or " 123-456-".

Formula would look like:
Code:
IF RIGHT(TRIM({Table.Field}),1) = "-" THEN ...

Cheers!

Mike
---------------------------------------------------------------
"To be alive is to revel in the moments, in the sunrise and the sunset, in the sudden and brief episodes of love and adventure,
in the hours of companionship. It is, most of all, to never be paralyzed by your fears of a future that no one can foretell."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top