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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Eliminating characters on a field

Status
Not open for further replies.

Barock21

MIS
Dec 27, 2005
23
0
0
US
I am trying to report a phone number, however the phone numbers stored on the database are set up XXX-XXX-XXXX. I need to get rid of the dashes and get the result as XXXXXXXXXX. Is there an easy way to do this?

Thanks.
B21
 
Try:

replace({table.phonenumber},"-","")

In 8.0 there was a problem with replacing a character with "", but it was resolved in later versions.

-LB
 
If you find that there are other characters as well, which is fairly common, you can sort it out this way:

whileprintingrecords;
stringvar currphone:= trim({table.phone});
stringvar Phone:="";
numbervar counter;
For counter := 1 to len(currphone) do(
if isnumeric(mid(currphone,counter,1)) then
Phone:=Phone + mid(currphone,counter,1)
);
if len(phone) <> 10 then
"*" & Phone
else
Phone

This will also flag bad phone number lengths with an asterisk if it isn't 10 characters.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top