Compare two Excel date with different Format

Good morning all,
I would like to compare 2 dates recovered from 2 Excel files.
The dates have a different format.
Ex: 12.06.2019 and 11/20/2020 00:00:00.
I can not put them in the right format in the DATATABLE to be able to compare them then.
Could you help me please ?
Thank you in advance.

Let’s say you’re checking that the 1st date is earlier than the 2nd date. Your comparison would look as follows.

If the 1st date is set to String variable Date1, and the second is a String variable of type Date2, then the comparison is:

DateTime.ParseExact(Date1.ToString, "MM.dd/yyyy", System.Globalization.CultureInfo.InvariantCulture) < DateTime.ParseExact(Date2.ToString, "MM/dd/yyyy hh:mm:ss", System.Globalization.CultureInfo.InvariantCulture).

Great, it works. Thank you.

And if I want to insert Date1 and Date2 in a new Datatable with the format dd / MM / yyyy. What are the right formulas for conversion ?
Thank you again for your help

If you want it inserted into a datatable with a specific format, you’ll need to use the Add Column activity to create a column of type String. Then you can insert Date1 in the For Each Row loop assigning row(“NewColumnName”) to DateTime.ParseExact(Date1.ToString, "MM.dd/yyyy", System.Globalization.CultureInfo.InvariantCulture).ToString("dd / MM / yyyy").