Date matching issue

Hello guys,
I am trying to manipulate dates using the below partial workflow:

I am trying to match startdate against CRDate + 3 years. Whatever date I use for startdate or CRDate, the IF statement always says that it’s ‘more than 3 years’.

I am not sure if I am using the correct code in the IF condition, but that’s what I have tried so far.

Can anyone please assist?

Hello @Clintonnn I did not get why you are >? covnerting string > Date > string >split

you can directly use CDate(strDate).AddYears(3) > Cdate(strDate2)

1 Like

Hi,

Is your date format “MM.dd.yyyy” or “dd.MM.yyyy”?

Anyway, perhaps you should compare them as DateTime as the following.

DateTime.ParseExact(CRDate,"MM.dd.yyyy",System.Globalization.CultureInfo.InvariantCulture).AddYears(3)>DateTime.ParseExact(startdate,"MM.dd.yyyy",System.Globalization.CultureInfo.InvariantCulture)

or

DateTime.ParseExact(CRDate,"dd.MM.yyyy",System.Globalization.CultureInfo.InvariantCulture).AddYears(3)>DateTime.ParseExact(startdate,"dd.MM.yyyy",System.Globalization.CultureInfo.InvariantCulture)

Sequence.xaml (6.9 KB)

Regards,

1 Like

Also in your if condition you are not matching dates, you are matching strings… thats why you are getting unexpected result

1 Like

Hi @Clintonnn ,

You can also use it as

1 Like

Thank you everyone for your very quick help!

I can only mark 1 answer as a solution but all gave different and valid ways of completing this calculation - I really appreciate it!

Thanks you so much again and have a great day! :slight_smile:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.