Compare previous date to today date

Hi guys
Hope you all fine my question is i have excel file where one column is due date ,and i need to fetch that date from excel and compare with current day in if condition how could i perform this the most important this my excel date is might be string so i need to convert it into datetime and fetch system date.
my if condition is my excel date is less then or equal to current date
please help me i appreciate

Hi @Aleem_Khan - Please share your date format and excel screenshot.

i am using this

DateTime.TryParseExact(row(“Due Date”).ToString.Trim,“dd-MM-yyyy”,System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None,Nothing)<=System.DateTime.Now.ToString(“dd-MM-yyyy”)

@Aleem_Khan – thanks…we understand you are using this…but we would like to know the exact format, so that we can help better…

Did you get any error? if so, what is it?

also sharing the screenshot or your excel file would be help here.

Hi @Aleem_Khan … You can try like this…

Assign Statement ==> DteDate = Datetime.ParseExact(row(“Date”).ToString,“dd/M/yyyy hh:mm:ss”,System.Globalization.CultureInfo.InvariantCulture)

Here DteDate is DateTime variable…

Even though the excel does not contain time, you have to give hh:mm:ss in the datetimeparse.exact…if not it will throw an error…

Input
image

Output

image

3 Likes

Nice solution :pray:

2 Likes

thank you prashant

@Aleem_Khan - Did it worked? if yes, please mark my post as solution , that will close this thread and help others to find the solution easily.

Sure thank you so much i appreciate you

1 Like

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