Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
Solved

# Crystal Reports Format Field with Dashes

Posted on 2016-09-21
Medium Priority
91 Views
Hello,

I have an 11 digit field that has to be separated with dashes.  For example, 11111111111 would need to change to 11111-1111-11.

Thanks for any help,

Mike
0
Question by:Michael Graham
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 3
• 2

LVL 35

Expert Comment

ID: 41809903
The simplest solution is probably a formula like this:

Picture (CStr ({your field}, "00000000000"), "xxxxx-xxxx-xx")

That converts the numeric field into an 11 character string, with leading 0's if necessary, and then uses Picture to insert the "-"s in the string.

James
0

LVL 101

Expert Comment

ID: 41809906
You could try using the CStr and Replace functions

Replace(CStr(11111111111,'######,####,##'),',','-')

Another method would be

Picture(CStr(11111111111,0,''),'xxxxxx-xxxx-xx')

mlmcc
0

Author Comment

ID: 41809926
Thank you.  Do you know where I would put this formula?
0

LVL 35

Accepted Solution

James0628 earned 2000 total points
ID: 41810003
Just create a new formula in the Field Explorer and then put that formula on the report.

James
0

Author Comment

ID: 41810045
okay,

this ended up working for me:

Left ({vw_reporting_biannualaudit.NDC},5 )+"-"
+Mid ({vw_reporting_biannualaudit.NDC},6 ,4 )+"-"
+Right ({vw_reporting_biannualaudit.NDC},2 )

Thank you for letting me know where to put the formula
0

LVL 35

Expert Comment

ID: 41810064
Yeah, that will work.  FWIW, if the field is a string, you could also use the Picture function that we mentioned.

Picture ({vw_reporting_biannualaudit.NDC}, "xxxxx-xxxx-xx")

If the field is not always 11 characters long, then you might need to check for that, depending on how you wanted to handle that.

James
0

## Featured Post

Question has a verified solution.

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

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
###### Suggested Courses
Course of the Month9 days, 13 hours left to enroll