Crystal Reports

George_Milton used Ask the Experts™
Hi. I have very little knowledge of crystal reports but was hoping someone could help with this. What I need to do is to create a formula that will match part of a reference and then enter text or number.
So reference is abc/12/1234562, I want crystal to match /12/ and then insert 2012 into the report. I have tried a few things in formulas such as wild cards, and so far no luck. The other issue is that the characters before and after the /12/ can vary.

Thanks in advance
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Need more informatio on requirements.

Are you saying that your report should only contain records that have /12/ in this field?
Or are you saying that some records in the report will have this but others in the report will not have  /12/?

And are you saying you want the field to appear in the form..  abc/2012/1234562?

If this last bit is what you want then you just create a formula field that is...

replace({table.field}, "/12/", "/2012/")


Hi, sorry for the lack of info.
What I have is a report that is produced, one of the fields is Year. Now unfortunately the DB does not produce the correct information. So I was trying to create a formula that would look at the field called reference, would then look for /10/ within that field and then output into the report as 2010. I do the same with another fields, that just contains 3 letters, so I have an if statement that looks at the field and =abc then totext testabc, I just don’t know how to tell crystal to only check for the /10/ and if that matches then totext 2010, and so on for /11/, /12/ etc.. I hope that make sense

Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013
Just like above.

If you need all 3 then use a formula with a variable

Local StringVar strOut;
strOut := {table.field};
strOut := replace(strOut, "/12/", "/2012/");
strOut := replace(strOut, "/11/", "/2011/");
strOut := replace(strOut, "/10/", "/2010/");
CompTIA Security+

Learn the essential functions of CompTIA Security+, which establishes the core knowledge required of any cybersecurity role and leads professionals into intermediate-level cybersecurity jobs.



I just want the year field to show 2012. Do not need any of the reference so, for example abc/10/123456 as /10/ is present the report will show 2010. Again apologies as I no real knowledge of Crystal
Local StringVar strOut;
strOut := {table.field};
if instr(strOut, "/10/")>0 then
else if instr(strOut, "/11/")>0 then
else if instr(strOut, "/12/")>0 then
""    /output nothing if values not found


Thanks that works, thank you very much, now if only I understood what it was doing!!!!

Again thanks very much

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial