Excel - Compare Dates

Hey,
I have an excel list with two dates that i would like to compare.
Bildschirmfoto 2020-03-14 um 14.59.49

I want to create a new column “Posting date in the previous month”. The bot should then check for each line whether the “posting date” is in the month before the “goods issue date”. If this is the case, a yes should appear in the cell in the column “posting date in the previous month” and the cell should turn red. Otherwise a no should appear and the cell should be colored green.

What do I have to write in the If condition to check whether the posting date is in the previous month from the goods issue date ?

Any help would be great :slight_smile:

Hello @RoboticApprentice,

You can read this excel into a datatable & this use a for each loop, within which you can convert data in two coulmns to Date format using the following code:

Date.ParseExact(row(“Goods Issue Date”).ToString,“dd.MM.yy”,system.Globalization.DateTimeFormatInfo.InvariantInfo)
Date.ParseExact(row(“Posting Date”).ToString,“dd.MM.yy”,system.Globalization.DateTimeFormatInfo.InvariantInfo)

Once both are converted to Date format you can use the > , < , = conditions to compare dates as if they were numbers !

Hope that helps. Kudos :slight_smile:

Regards,
Nithin

A post was merged into an existing topic: Excel - Compare two Dates and add a new Column