Solved

Crystal Reports Format Field with Dashes

Posted on 2016-09-21
6
59 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
[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
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 35

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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 35

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 35

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

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 …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

749 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