Solved

Crystal Reports formatting phone number

Posted on 2014-04-18
2
3,109 Views
Last Modified: 2014-04-22
I have the following formula to format a phone number:

Picture(ToText({TABLE.FIELD}), "(xxx) xxx-xxxx")

But the result contains 2 decimal places, such as (555) 123-4567.00

Why is the .00 on there when I am converting it to text? I have tried:

Picture(ToText(Round({TABLE.FIELD},0)), "(xxx) xxx-xxxx")

But I still get the .00
0
Comment
Question by:altosax
2 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 40009833
Unless you tell ToText and CStr how to format the number, it uses the system default which is generally 2 decimals

Try

Picture(ToText({TABLE.FIELD},0,""), "(xxx) xxx-xxxx")

That says 0 deicmal places and no thousands separator

You could also use

Picture(ToText({TABLE.FIELD},"0000000000"), "(xxx) xxx-xxxx")

mlmcc
0
 
LVL 34

Accepted Solution

by:
James0628 earned 500 total points
ID: 40010241
If any of your phone numbers are 7 digits, with no area code, you may want to try to handle that.  mlmcc's second suggestion would put 0's where the area code would be, which may be good enough.  Another option would be the following, which would leave the area code blank if there were only 7 digits.

Picture(ToText({TABLE.FIELD}, "##########"), "(xxx) xxx-xxxx")


 James
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now