Compare two dates that are string

Hello you all,

I’m having trouble will trying to compare 2 dates.
I need to compare a date that i read out of a PDF in the following format dd-MM-yyyy.
I need to compare this date to the date of today and i get it like this: now.tostring(“dd-MM-yyyy”)
Have tried it with a if and compare date but can’t get it to work.

Thanks in advance for your help,

Hi @jvspaendonk,

To compare dates, you need to have them in DateTime format (Not String)
So, to convert string date (dd-MM-yyyy) in DateTime format just use following code in Assign activity.

Date1 = DateTime.ParseExact(StrDate, "dd-MM-yyyy",System.Globalization.CultureInfo.InvariantCulture)

Here, in code you can see that, there’s a variable StrDate (type String) holding your string date.
Date1 is of type DateTime

So as you have var Date1 (DateTime) holding specified date.
You can compare as you want it with today’s date in If activity with condition

—> Date1 > DateTime.Today


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