I have a field in crystal report with the following data:
'605 KL1 - Daniel Steve'
How can i just remove the '605 KL1 - ' and leave the 'Daniel Steve' in the field only?
Characters before '-' could be different, i hope the formula would automatically search for the '- ' and then show everything after it.
Answer: Use the inStr() function to locate the first asterisk. Then use the Mid() function to grab everything to the left of the asterisk.
instr = The instr function returns the position of the first occurrence of one string within another. This position is based on a 1 based index of the characters in the string. *For additional information and examples on formula functions, please go to Help, Crystal Reports Help from within the Crystal Reports program.
A database field is defined as string data type, contains numeric characters. To perform calculations or summaries such as a sum or an average, the field must be defined as a number data type. How to convert a string field containing numeric characters to a number field in Crystal Reports?
Use Subscript (x[y]) Crystal Syntaxsub
field_name ='605 KL1 - Daniel Steve'
The syntaxis {field_name}
[11 to 23]
Result = {field_name}
[11 to 23] -> Result = 'Daniel Steve'
Website reference: IBM - Developing Crystal Report
MID
can help here:
MID(my_string, 11) // will print your string from character 11 ("D") forward
And you can combine MID
with INSTR
if you need the display to be dynamic (of course this will only work if your data have a consistent format):
MID(my_string, (INSTR(my_string, "-") + 2))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With