How to write a if condition to check weather the date in the date column of the present row in excel is equal to days date or previous date

How to write a if condition to check weather the date in the date column of the present row in excel is equal to days date or previous date

Hey bpt.teja1996.Given you’ve formatted the dates from Excel as dates, you can put this condition in your if (which again is in a For Each Row):

datetime.ParseExact(row.item(“Date”).ToString,“MM/dd/yyyy hh:mm:ss”,System.Globalization.CultureInfo.InvariantCulture) <= datetime.Now

Kind regards, Anders

Hi Anders,
Can you help with this
I have (A)string in the format dd/MM/yy… how do I assign it basically I don’t perform some calculation… I have another (B)date value from excel… I need find difference between B-A
I have assigned date value based on your suggestion… not sure how I can assign the string and use it for calculation

1 Like

Hey mbsatya

You can just do it with the same syntax:
datetime.ParseExact(“16/06/20”,“dd/MM/yy”,system.Globalization.CultureInfo.InvariantCulture)

Did that help? :slight_smile:

Kind regards, Anders

2 Likes

Hi Anders,

It worked. Thank you so much

1 Like

Awesome :slight_smile: