Skip to main content
Solved

How to format phone number

  • June 19, 2020
  • 1 reply
  • 67 views

rich90599
Contributor
Forum|alt.badge.img+4
Hello,

I have a 10 digit phone number in an attribute (e.g. 0123456789).

However, I want to output it formatted to a string like this: 012-345-6789.

How would I go about doing this?

Any help would be much appreciated.

Thanks

Best answer by ebygomm

Take 3 from the left, add a hyphen, 3 from the middle add a hyphen, 4 from the right

@Left(@Value(phone),3)-@Substring(@Value(phone),3,3)-@Right(@Value(phone),4)
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

1 reply

ebygomm
Influencer
Forum|alt.badge.img+44
  • Influencer
  • 3427 replies
  • Best Answer
  • June 19, 2020

Take 3 from the left, add a hyphen, 3 from the middle add a hyphen, 4 from the right

@Left(@Value(phone),3)-@Substring(@Value(phone),3,3)-@Right(@Value(phone),4)