If: String was not recognized as a valid DateTime

Hello, Family’s I get error

If: String was not recognized as a valid DateTime.

when I just compare the date in excel and today date in excel
Can any one plz help me
i use this code to compare the excel date.
DateTime.ParseExact(row("Date").ToString.Trim,"dd/MM/yyyy HH:mm:ss",System.Globalization.CultureInfo.InvariantCulture)=Today
image
Date format dd/MM/yyyy

I hope i get a solution from you

Thanks
Chethan P

Hi,

Can you try "dd/M/yyyy" instead of "dd/MM/yyyy HH:mm:ss"?

Regards,

1 Like

Its working can you please explain I didn’t get. explain that Datetime.ParseExact(newstring,“dd-MM-yyyy”,System.Globalization.CultureInfo.InvariantCulture)

Thanks
Chethan P

Hi,

MM means exact 2 digits of month. So your data 26/8/2021 fails. On the other hand, M can handle 1 or 2 digits of month.

Regards,

1 Like

and what is the datetime.parseExact and globilaization.cultureInfo.InvariantCulture

Hi,

The following document will help you.

Regards,

1 Like

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