How to convert dateTime column to Text in DataTable using enumerable

Hi Mates,
can you help me please how to convert dateTime column to Text in DataTable using enumerable or without for each activity?
Thanks

Hello @nlcollado, welcome to forum.
any perticular row index?

i tried this code

DT2.AsEnumerable().Where(Function (x) x(“Date Purchased”).SetField(Convert.ToDateTime(x(“Date Purchased”)).ToString(“MM/dd/yyyy”))).CopyToDataTable

but it is returning some late binding error

basically i have a DataTable named DT2 which contains “Date Purchased” column, i want that column to be converted to text. is this possible via enumerable? thanks

Is it single row table? or you want all values of this column in linear text?
Example of what is in table and what output you want would help

here’s sample table
image

i want column A to be like this
image

I understand that you need to update format of excel.
I see for each as appropriate solution

yep i can do this via for each row but i was wondering if this can be done via linq or as enumerable :slight_smile:

Via linque selecting is possible, but if you want to update back in table then that will be difficult

@nlcollado
updating a column within a LINQ statement in an assign is technically not possible. SetField is a sub (subroutine as Lambda/action) and is not returning a value. The LINQ chain/processing Pipeline requires returns as the Assign L-value (Left side value) needs to get set.

Currently the error from screenshot is thrown as setField is to use in the form of:
setField(Of YourColumnDataType)(…
Once you will have correct it, then you will get a message similar there is not return value…

Use For each (recommended)
With a Blackboxing invoke code you could get it run, but you will reduce with this the possibilty of maintainabilty and tracing the flow