Error then read datetime format from Excel

Hi Everyone.

I have trouble but do not know anyway to resolve. I have tried to find all of thread but still same.

The excel file has a column with Date format ( dd/MM/yyyy)… but it has problem when i read it to convert the format which i want.

I have tried to convert into many way such as :

  • Convert.ToDateTime(row(“Date”).ToString)
  • Datetime.ParseExact(row(“Ngày giao dịch”).ToString,“dd/MM/yyyy”,System.Globalization.CultureInfo.InvariantCulture).ToString(“dd/MM/yyyy”)

Before convert it into format i want, i have read it first and it show result as below picture. But it still error after i convert.

How to resolved this issue?

Thanks in advance!

Use this below code @Mr.H
Datetime.ParseExact(“20/11/2020”,“dd/MM/yyyy”,System.Globalization.CultureInfo.InvariantCulture).GetType put this in message box and check the type.


Hi Bro.

It still show the error : “Message Box: String was not recognized as a valid DateTime.”

Can you trim the variable : Out_NgayGiaoDich_New.ToString.Trim and check @Mr.H ?
Beacuase Im not getting any error in my machine Or it can be due to whitespace present in the Out_NgayGiaoDich_New value.


Hi Bro.

Thanks you very much.

I think the command : Mydate.ToString.trim is correct before convert into new format

@Mr.H :slight_smile: :+1:

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