String was not recognized as a valid DateTime when read cell with date format

Hi Everyone.

I have cell with date format ( dd/MM/yyyy ) : 20/11/2020

But i have received an error as title when read it. I have tried some ways as below

DateTime: Date_Text = Convert.ToDateTime(row(“Date Column”).ToString)

DateTime: Date_Text = Datetime.ParseExact(row(“Date Column”).ToString,“dd/MM/yyyy”,System.Globalization.CultureInfo.InvariantCulture)

How to do resolve this issue?

Thanks in advance!

@Mr.H - Could you please print the output of Date_Text after the first statement to see what is the format it is printing?

1 Like

Hi Bro.

I have print it before convert and received : 20/11/2020

@Mr.H - Please try like below : dd/MM/yyyy HH:mm:ss

See example below: My Input


DateTime.ParseExact(row(“Receiption Date”).ToString,“MM/dd/yyyy HH:mm:ss",System.Globalization.CultureInfo.InvariantCulture).Tostring(“dd-MM-yyyy”)



Thanks you bro.

But my date format is different to your sample.

I will try to find another way with VBA.

@Mr.H - Please look closely…My format and your format are same(yours is dd/MM mine is MM/dd)…I am asking you to try adding HH:mm:ss at the end … dd/MM/yyyy HH:mm:ss…

If you see my input i dont have HH:mm:ss value, but after adding that value it worked…

Why can’t you give it a try?

1 Like

Thanks you Bro.

I have tried your way combine and found the solution for my case.

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