Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Phone Number Post Reply Post New Topic
Author Message
Kitty1
Senior Member
Senior Member
Avatar

Joined: 14 Apr 2010
Online Status: Offline
Posts: 159
Quote Kitty1 Replybullet Topic: Phone Number
     Posted: 09 Dec 2014 at 4:59am
Hi, how do I format a phone number from 8005555555 to (800)555-5555 ?

Thanks!
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 09 Dec 2014 at 7:16am
Found this after a quick internet search.

Picture(ToText({TABLE.FIELD}, "##########"), "(xxx) xxx-xxxx")
IP IP Logged
Kitty1
Senior Member
Senior Member
Avatar

Joined: 14 Apr 2010
Online Status: Offline
Posts: 159
Quote Kitty1 Replybullet Posted: 09 Dec 2014 at 7:44am
didn't work. :(
IP IP Logged
Kitty1
Senior Member
Senior Member
Avatar

Joined: 14 Apr 2010
Online Status: Offline
Posts: 159
Quote Kitty1 Replybullet Posted: 09 Dec 2014 at 7:45am
thanks for your reply though!
IP IP Logged
Kitty1
Senior Member
Senior Member
Avatar

Joined: 14 Apr 2010
Online Status: Offline
Posts: 159
Quote Kitty1 Replybullet Posted: 09 Dec 2014 at 8:37am
I tried this:

Picture(ToText({V_CUSTOMER_MASTER.TELEPHONE}), "(xxx) xxx-xxxx")

and it is returning this:

(   ) 800-3234340

I am so close to getting it, but can't figure out why it would be putting the ()'s before the number...
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 09 Dec 2014 at 10:08am
Is the field {V_CUSTOMER_MASTER.TELEPHONE} text or numeric?

Another way, assuming a numeric field.  Not as pretty, but should work.

stringvar phnum := totext({V_CUSTOMER_MASTER.TELEPHONE},0,"");

"("+left(phnum,3)+") "+mid(phnum,4,3)+"-"+right(phnum,4)
IP IP Logged
Kitty1
Senior Member
Senior Member
Avatar

Joined: 14 Apr 2010
Online Status: Offline
Posts: 159
Quote Kitty1 Replybullet Posted: 09 Dec 2014 at 10:31am
Hi kevlray. I feel so stupid...i thought the phone number field was a 10 digit field, but there is also provision for a country code in the file. All is well now. :) Thanks so much!
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum