Solved

Crystal Reports Format Field with Dashes

Posted on 2016-09-21
6
47 Views
Last Modified: 2016-09-21
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
Comment
Question by:Michael Graham
  • 3
  • 2
6 Comments
 
LVL 34

Expert Comment

by:James0628
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 100

Expert Comment

by:mlmcc
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

by:Michael Graham
ID: 41809926
Thank you.  Do you know where I would put this formula?
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 34

Accepted Solution

by:
James0628 earned 500 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

by:Michael Graham
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 34

Expert Comment

by:James0628
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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

Suggested Solutions

Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
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 …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

773 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