How to check if a date is older then 7 days in UiPath studio . the day is with format “MM/dd/yyyy” here an exemple “02/23/2023” .
what are the steps to convert this string date “02/11/2023” ( “MM/dd/yyyy” ) to datetime and what is the condition that i can know that this date > 7 days or no
if Date.today.adddays(-7) < Var_YourDate
Hello @aya.lajili
you can try below in log message
DateTime.ParseExact("02/23/2023","MM/dd/yyyy",Nothing) < Today.AddDays(-7)
1 Like
Another way to do it is with the DateDiff method.
DateDiff("d",DateTime.ParseExact("02/23/2023","MM/dd/yyyy",system.Globalization.CultureInfo.InvariantCulture),Now)
That will tell you the number of days between 02/23/2023 and Now. Of course, you’d want to replace “02/23/2023” with your variable containing your string date.
Hi @aya.lajili ,
When the format is MM/dd/yyyy
we could shorten the Parsing by using the CDate()
method.
You could then use the below Expression :
DateDiff("d",CDate("02/23/2023"),Now)>7