| Author |
Message |
Kitty1
Senior Member
Joined: 14 Apr 2010
Online Status: Offline
Posts: 159
|

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 Logged |
|
|
|
kevlray
Admin Group
Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
|

Posted: 09 Dec 2014 at 7:16am |
|
Found this after a quick internet search.
Picture(ToText({TABLE.FIELD}, "##########"), "(xxx) xxx-xxxx")
|
IP Logged |
|
Kitty1
Senior Member
Joined: 14 Apr 2010
Online Status: Offline
Posts: 159
|

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

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

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 Logged |
|
kevlray
Admin Group
Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
|

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 Logged |
|
Kitty1
Senior Member
Joined: 14 Apr 2010
Online Status: Offline
Posts: 159
|

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 Logged |
|
|
|