Print Page | Close Window

Finding one letter in a string

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Tips and Tricks
Forum Discription: Have you learned some great tricks to share with the group? Post them here!
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=19980
Printed Date: 04 May 2024 at 8:47pm


Topic: Finding one letter in a string
Posted By: AmyTheJoy
Subject: Finding one letter in a string
Date Posted: 03 Sep 2013 at 12:02pm
Hello,

I need a formula I can use to find a "P" at the end of a string. That is, if I have samples 99991 99992 99993 99994 99995P and 99996, I want to be able to write a formula that will give me "P" as an answer when it sees 99995P. I need to eliminate the rest of the string data... or write an If-Then statement that gives me a "P" when it sees that letter. It gets trickier, because I do not know how many digits a sample might have. It may be 444 445 446P 4447, or 11111112 11111113P 11111114 etc.

Can somebody assist?



Replies:
Posted By: DBlank
Date Posted: 04 Sep 2013 at 4:07am
not sure i fully understand what you want it to do but you can easliy find if the string has a P in it using instr().
instr(field,"P")>0


Posted By: AmyTheJoy
Date Posted: 04 Sep 2013 at 4:56am
Actually, what you just gave me was all that I needed. Thanks a ton. I used this formula to find "P", and then I wrote another formula based on whether that first formula gave a True or False answer. And it works great. Thanks!



Print Page | Close Window