Print Page | Close Window

Substring and Instr together

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=17842
Printed Date: 01 May 2024 at 1:19pm


Topic: Substring and Instr together
Posted By: crystalgal
Subject: Substring and Instr together
Date Posted: 25 Oct 2012 at 4:16am
Hello,

I am having an issue using Substr and Instr and need some help.
right now I have
field:
asdfg - itsnoteasy - whattodo

I don't need - whattodo from the field

I used substr(field, instr(field,'-',1)) as name,
but not working.
Any help is appreciated.

TIA



Replies:
Posted By: DBlank
Date Posted: 25 Oct 2012 at 4:55am
do you mean you want to return
"asdfg - itsnoteasy"
?


Posted By: crystalgal
Date Posted: 25 Oct 2012 at 4:57am
yes and I tried all the combinations after Instr but is not working.

Thank you.


Posted By: DBlank
Date Posted: 25 Oct 2012 at 5:07am
mid({table.field},1,instrrev({table.field}," - "))


Posted By: crystalgal
Date Posted: 25 Oct 2012 at 5:34am
Thank you but is it possible to use substr and instr as I need this field not as a formula and I am trying to use as a sql in the report.
TIA


Posted By: DBlank
Date Posted: 25 Oct 2012 at 5:45am
I do not understand what you mean by "use as a sql in the report"?


Posted By: crystalgal
Date Posted: 25 Oct 2012 at 5:58am
I am using pl/sql to get the fields for this report and this particular field I need as a parameter. I have seen that if it is a formula, Crystal does not show in the list to pick for the parameter.

Thank you


Posted By: crystalgal
Date Posted: 25 Oct 2012 at 6:19am
I got by using this.
substr(field,0, instr(field,'-',1,2)-1)

Thank you very much. You are always there/here when I need it.:-)



Print Page | Close Window