Unable to Compare dates of different format

Hi, I’m trying to compare two Date which is in String format (5/27/2021, 10/28/2021). I want to compare these two dates and perform activities based on the difference. When i tried to get some help from Forum i found “DateDiff(DateInterval.Day, Convert.ToDateTime(firstDate), Convert.ToDateTime(secondDate)” but when i implemented it I’m not sure about the variable type i should choose while assigning it to a variable, which causes exception “Expression is not an array or a method, and cannot have an argument list”

Kindly help me to find the difference between two dates. Thanks!


Welcome to UiPath Community!

Check similar to this, it is working.

I think DateDiff returns an integer. Also, you might have better luck with Date.Parse(firstDate) instead of Convert.ToDateTime(firstDate).

Also, you are missing the last ) at the end of your DateDiff expression.

Thank you so much @sarathi125 . It worked like a charm !!

1 Like

Hi @postwick , I tried with the variable type as Integer but still faced the same error. Will try Date.Parse(firstDate) Thank you!

Missed the “)” while copy pasting.

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