Help with substring

This is the if condition:
withoutMoney.Substring(0,withoutMoney.IndexOf(year, withoutMoney.IndexOf(year)+1)+year.Length)

This is the code: Left(withoutMoney,withoutMoney.Tostring.LastIndexof(year)+4)

withoutMoney is a string variable.
year is a string variable to get the date(DateTime.Now.ToString(“yyyy”))

This is an example of line that is suppose to pass through if condition and my code.

The expected outcome was S|Compute|Service(JYAZ,|4|vCEU|8UB,|99.5%)|01|May|2018|to|31|May|2017|

But the outcome is S|C

It worked before but now it’s not working after i changed my input file. Pls help.

Thank you xoxo

if Input is : S|Compute|Service(JYAZ,|4|vCEU|8UB,|99.5%)|01|May|2018|to|31|May|2017|1,094.74
and output is : S|Compute|Service(JYAZ,|4|vCEU|8UB,|99.5%)|01|May|2018|to|31|May|2017|
you can do withoutMoney.Substring(0,withoutMoney.Tostring.LastIndexof("|")+1)

Hi @sangasangasanga

Could you clarify something for me? I am a bit confused by your IF statement with a .Substring method and its purpose.
If the entire IF statement looks like this:

withoutMoney.Substring(0,withoutMoney.IndexOf(year, withoutMoney.IndexOf(year)+1)+year.Length)

Then I am not sure how you managed to use a String value in that IF statement without a syntax error, for example for me it gives an error about conversion from String to Boolean:

Could you clarify the purpose of this IF statement? Maybe I am missing something :slight_smile:

Hi, sorry this is how my if condition looks like: :sweat_smile:
withoutMoney.Substring(0,withoutMoney.IndexOf(year, withoutMoney.IndexOf(year)+1)+year.Length).Length > 50