Two date comparison

Hello friends,

I have two dates.
for example : Date 1 is 14/04/2022 and Date 2 is 19/04/2022
I need to check Date2 is greater than day1 then how we can check ?

Hi @Rup_1

Use

Datetime.compare(Datetime.ParseExact(date1,"dd/MM/yyyy",System.Globalization.CulturalInfo.InvariantCulture),Datetime.ParseExact(date2,"dd/MM/yyyy",System.Globalization.CulturalInfo.InvariantCulture))

The output would be

<0  - Date1 earlier to date 2
0 - both equal
>0 - Date 2 earlier to date 1

Cheers

We parse the string into a datetime like:
grafik

myDate1 = DateTime.ParseExact(strDate1, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture).Date
myDate2 = DateTime.ParseExact(strDate2, "dd/MM/yyyy", System.Globalization.CultureInfo.InvariantCulture).Date

then we can compare it e.g myDate1 < myDate2

HI @Rup_1

Check out this video link

Regards
Gokul

Hello @Rup_1

You can use modify Date activity and provide the operation. Then you can use an if condition to check the value.

https://docs.uipath.com/activities/docs/modify-date

Thanks

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