Crystal Reports - Trim Data

Hello,

I’m wanting to trim a field.

I have a product code like the following:
100003.BLK.SML
104+YEL+LRG
1005-GRE-XLG

I need to trim the code so it appears like below taking into account the following characters . + / * -

100003
104
1005

The code length can’t exceed 16 characters.

Thank you
jspcAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
mlmccConnect With a Mentor Commented:
Will the front part always be numeric?
If so, My formula should work.


If it can include non-numeric data then try

SPlit(Replace(Replace({YourField},'+','.'),'-','.'),'.')[1]

Open in new window


mlmcc
0
 
Ryan ChongCommented:
what's your backend database? are you able to manipulate the data from backend source instead?
0
 
jspcAuthor Commented:
SQL Database
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
mlmccCommented:
DO you just need the leading numeric part?
If so use

Val({YourField})

Open in new window


If you want it as a string use

CStr(Val({YourField}),0)

Open in new window


mlmcc
0
 
jspcAuthor Commented:
yes just front front part as per my example
0
 
mlmccCommented:
My String formula will result in a comma

use
1:CStr(Val({YourField}),0,'')

Open in new window

0
 
jspcAuthor Commented:
Bingo! Thanks
0
All Courses

From novice to tech pro — start learning today.