Check if Date1 is a few days more than Date2

Hi guys,

I learnt from other post on the following expression to compare if Date2 is more than Date1 plus 1 year time:

Can anyone kindly share with me if I wanted to compare Date2 is more than Date1 plus 30 days, how should I draft the expression?

At first I thought it is something like: Date1.AddDays(30)<Date2
But it is not correct :joy:

PS: My Date1 and Date2 are stored in this format : 09-OCT-2019


Use this
DateDiff(DateInterval.Day,DateTime.ParseExact(str_Date, “dd-MMM-yyyy”, CultureInfo.InvariantCulture),

Thanks. I actually intend to write an expression into my IF condition such as:

If Date1.AddDays(30) <= Date2
then …

In this case, Could advise me on the way to write expression?

are you reading from the datatable?

Date1 read from data table (extracted from Excel)
Date2 read from system date (aligned the format with Date1)


Try something like this,

DateDiff(DateInterval.Day, DateTime.ParseExact(date1, “dd-MMM-yyyy”, System.Globalization.CultureInfo.InvariantCulture),DateTime.ParseExact(date2, “dd-MMM-yyyy”, System.Globalization.CultureInfo.InvariantCulture)) < 30

Here my date1 and date2 are string datatype variables which holds date values.

Have to import System.Globalization namespace in UiPath Imports section to use CultureInfo.

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