How can I convert the data in this excel into DataTime type?

Hi,everyone

I read the follow excel in the Studio Pro (Version: 2020.4.3), and save it into the datatable, but I can’t convert the data into DataTime type?

date_limit.xlsx (8.2 KB)

Hi @chenyanshan_gz

Try this

DateTime.ParseExact(dt.rows(0)(0).ToString,"yyyy-M-dd",System.Globalization.CultureInfo.InvariantCulture)

Regards,

Hi,

Thank you for your response, but it still throws an error.

Regards,

Hi,

It seems same matter with the following topic.

There are many extra characters (0x200e) in your date string.

Can you try to remove them then convert to datetime as the following?

CDate(dt.Rows(0)(0).ToString.Replace(Chrw(&H200e),""))

Sample
Sample20240821-2.zip (8.5 KB)

Regards,

1 Like

Hi, @Yoichi

Thanks for the answer. This table is indeed an extract derived from the text within the referenced topic. It looks like it was a success in getting date data, but it’s not. Extra characters have also been extracted. In the referenced topic, the same problem has been solved by you, thank you sincerely.

Regards,

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