Question Regarding Date Comparison

In an excel spreadsheet I have a date “6/7/2019” which I need to compare with a date scraped from the web application “06/07/2019”.

UiPath says the Strings are not equal because the zeros are missing. How do I make sure the comparison returns true for all cases like this? e.g. (10/09/2019 and 10/9/2019 should return True if compared).

Hi Jayant,
You can use DateTime.ParseExact(“6/7/2019”,“d/M/yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yyyy”) to convert it to “06/07/2019” value and then compare the two strings using dt.Equal(dt2).
.xaml file attached for your reference.

Kind Regards,
pankajDateComparision.xaml (5.3 KB)

2 Likes

Hi @Jayant_C

you need to format your string first and compare it.
Datetime.ParseExact(In_string.ToString,“MM/dd/yyyy”,System.Globalization.CultureInfo.InvariantCulture)

cheers :smiley:

Happy learning :smiley:

1 Like