Clintonnn
(Clinton)
August 18, 2021, 7:55am
1
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
Yoichi
(Yoichi)
August 18, 2021, 8:10am
3
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
Clintonnn
(Clinton)
August 18, 2021, 10:33pm
6
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!
1 Like
system
(system)
Closed
August 21, 2021, 10:34pm
7
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.