Link to home
Start Free TrialLog in
Avatar of Becky Edwards
Becky EdwardsFlag for United States of America

asked on

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?
ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of James0628
James0628

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