Convert excel general format to date type issue

Hi,

I have an excel with date value but in general format, I want that to be converted to date value and replace it to same table, example the table has value like 43759 but when we convert it should be 03-14-2012.

I tried different methods like clone table and get type and add the value back to dt but didnt work, also tried below code but gives error.
DT= (From row In DT order by DateTime.FromOADate(row.item(Date).ToString(“MM/dd/yyyy”)) Select row).CopyToDataTable

Please let me know the correct way to do it.

Thank youSample_Datetime.xlsx (9.9 KB)

Hi @antoromeo18,
If you want to order a Enumerable object, you can’t order String variables but DateTime can be used for ordering. If you delete ToString(“MM/dd/yyyy”), I think you can get result.

Cheers :slight_smile:

Its is not working. Is there any other method to convert general format to date and rewrite in the data table?

Hi @antoromeo18,
I just saw your reply, I hope you found your answer but If not I’m gonna tell you.

The code I quoted below, You wanna use DataTable LINQ you should use like that
(From row In DT.AsNumerable() order by DateTime.FromOADate(row.item(Date)) Select row).CopyToDataTable

I forgot the mention before :slight_smile:
Cheers.

1 Like

It works, thank you. The other way to not get into this issue is by preserving format at read range activity.

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