Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parsing data from a field in Crystal

Status
Not open for further replies.

mrichey

MIS
Nov 22, 2002
71
US
I am trying to parse the information shown below.
Here is what is in the field now:
300b - Central Mortgage - Login
I want to see only what's to the left of the SECOND Dash.

I've tried the following formula but while the checker sees no errors, it blows up the program. The Node.Description field holds the data shown above.

left ({Node.Description},4) & " - " & mid ({Node.Description}, 8, (instr (10,{Node.Description},"-")))

Any Ideas? Thanks so much!!
 
What database are you using, and what is the field type?

It may be blowing because the conmdition doesn't exist, try:

if (instr (10,{Node.Description},"-") > 0 before you do the mid()
else
just display the field

Or

Crystal 8.5 and below only supports 254 characters or less, so this may explain the blow up (and it shouldn't be showing the field as a choice from within the data explorer if it's potentially longer than 254).

I'll assume that it's under 254 and demonstrate a Crystal solution (BTW, if you're using a SQL database, you can use a SQL Expression to construct this more effectively):

if (instr (6,{Node.Description},"-") > 0 then
left({Node.Description},5)+ mid({Node.Description}, 6, (instr ({Node.Description},"a")-6))

-k kai@informeddatadecisions.com
 
It occurred to me that you had some spaces in there, so my start numbers may be off, or you could just use:

if instrrev({Node.Description},"-") > 6 then
left({Node.Description}, instrrev({Node.Description},"-")-1)
else
{Node.Description}

-k kai@informeddatadecisions.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top