开发者

Using substring in crystal report

开发者 https://www.devze.com 2023-01-02 17:52 出处:网络
I have a field in crystal report with the following data开发者_StackOverflow社区: \'605 KL1 - Daniel Steve\'

I have a field in crystal report with the following data开发者_StackOverflow社区:

'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.


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))


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


I think u can also use Split function like that

Split ({field_name},"-")[2]

But if you want to use split function,u must make sure delimiter exist in the string or add some condition to prevent runtime error. Split function returns an array but it's doesn't start with zero. Its mean [1] is first room and [2] is second room.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号