Date Comparison between String_Date and Date_Time

Hello all, can someone share a workflow or explain how can I compare 2 dates,
date_1 and current_date(today’s date).

Here date_1 is the date (in 15/03/2023 format) that I have captured using get text. Now I have to compare date_1 and current_date in such a way that the date_1(i.e captured date) should always be greater/ahead than current_date. If yes then perform some action, and if no then skip it.

Regards,
Hardik Durgam.

@Hardik_Durgam

You can try like this

DateTime.Compare(Date_1,Now)

  • <0 − If date1 is earlier than Now
  • 0 − If date1 is the same as Now
  • >0 − If date1 is later than Now

Use it accordingly. And if date_1 is in string then use Cdate(Date_1)

Cheers

@Anil_G there’s an activity name ‘Compare Date’, are you suggesting me to use that?

Regards,
Hardik Durgam.


We parsed the string into a DateTime and then checked it

Kindly Note: Samplestring was set to the 17th as today is the 15th and we showcased the greater then today case

@Hardik_Durgam

This is an expression you can use this in if condition like this…

DateTime.Compare(Date_1,Now)>0

On then side you will have the date1 as greater and on else side you will have Now as greater

You can use the activity as well if you are comfortable

Cheers

Hi @Hardik_Durgam

Give a try to this

Workflow
DateCompare1.xaml (5.9 KB)

Hope this helps.