Home
Crystal Reports Training
Crystal Reports XI
Crystal Reports .NET
Crystal Reports Forum
News
Tech Support
Active Topics
Memberlist
Search
Help
Register
Login
Report Design
Crystal Reports Forum
:
Crystal Reports 9 through 2022
:
Report Design
Topic: truncate with a variable field length
Author
Message
dhazen
Newbie
Joined: 11 May 2010
Online Status: Offline
Posts: 7
Topic: truncate with a variable field length
Posted: 11 May 2010 at 5:53am
I have a field that contains data that looks similar to the following:
TIRD-64-1.125-US
TIPL-2-2-US
I need to capture only the data up to the second hyphen. I cannot use the left or mid as the field length varies. Any suggestions?
I am trying to retrieve only the TIRD-64 and the TIPL-2.
Thank you!
Deb
IP Logged
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Posted: 11 May 2010 at 6:41am
Maybe:
left({field},
instr(
(instr(
{field},'-')+1
),
{field},'-')-1
)
IP Logged
dhazen
Newbie
Joined: 11 May 2010
Online Status: Offline
Posts: 7
Posted: 11 May 2010 at 9:14am
That worked great!
Thank you!
Deb
IP Logged
dhazen
Newbie
Joined: 11 May 2010
Online Status: Offline
Posts: 7
Posted: 19 May 2010 at 11:12am
Here's another one...
TIRD-64-.071-US and
TIRD-2-1.4375-STA-US
I'm trying to capture only the .071 and the 1.4375
Any suggestions on how to capture the data AFTER the second hyphen?
Thank you!
Deb
IP Logged
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Posted: 19 May 2010 at 11:24am
I am sure there is a more elegent loop process but i think this will work:
mid({field},
instr(
(instr({field}
,'-')+1
),
{field}
,'-')+1
,
instr(
instr(
(instr({field}
,'-')+1
),
{field}
,'-')+1,
{field}
,'-'
)-
(instr(
(instr({field}
,'-')+1
),
{field}
,'-')+1
)
)
IP Logged
dhazen
Newbie
Joined: 11 May 2010
Online Status: Offline
Posts: 7
Posted: 20 May 2010 at 4:38am
This works!
Thanks again Master!
Deb
IP Logged
Printable version
Forum Jump
-- Select Forum --
Announcements
Talk with the Author
Self-Publishing
Job Postings
New feature request
Report Design
Data Connectivity
Technical Questions
Tips and Tricks
Crystal Xcelsius
Report Design
Data Connectivity
Writing Code
Tips and Tricks
Report Design
Data Connectivity
Writing Code
Tips and Tricks
You
cannot
post new topics in this forum
You
cannot
reply to topics in this forum
You
cannot
delete your posts in this forum
You
cannot
edit your posts in this forum
You
cannot
create polls in this forum
You
cannot
vote in polls in this forum
HOME
|
FREE EBOOK
|
PROGRAMMING GUIDE
|
PURCHASE
|
REVIEWS
|
CONTACT ME
|
FAQ
|
LINKS
|
PRIVACY
|
CLICK PLAYS
|
BAEZL
© 2004-2026 Brian Bischof. All Rights Reserved.