# Reformat number to phone number format in Crystal Reports XI

The number is a number in a table.  It shows up like this "8,765,230"   I need it to display like a phone number 234-5789.  I know this is a real no-brainer for most of you, but I have never had to do it, and can't find it anywhere in help menu.  You would think it would be easy to find.

How can I accomplish this?
###### Who is Participating?

x
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.

Commented:
Try this idea

Replace(CStr({YourNumber}/10000,4),'.','-')

mlmcc
0

Experts Exchange Solution brought to you by

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

Commented:
Will the number always be 7 digits?  If so, then mlmcc's suggestion is probably about as good as anything else.

If some numbers will be 7 digits and some will be 10 (with an area code), then:

If you want the area code to be completely blank (no ()) when there is no area code, you could use something like the following (using mlmcc's suggestion for the 7 digit numbers):

if Length (CStr ({phone}, "#")) = 10 then
Picture (CStr ({phone}, "#"), "(xxx) xxx-xxxx")
else
Replace (CStr ({phone} / 10000, 4), '.', '-')

If you want the area code on the 7 digit numbers to show as "(   )", you could just use:

Picture (CStr ({phone}, "#"), "(xxx) xxx-xxxx")

James
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
Crystal Reports

From novice to tech pro — start learning today.