Becky Edwards
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?
How can I accomplish this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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