Convert datatable strings column to datetime

@Angelo_Savino
In General the LINQ Syntax should/could look like following

(From row In Compressed2.AsEnumerable
Let dt= DateTime.ParseExact(row.Item(“Column2”).ToString,“dd/MM/yy”,Globalization.CultureInfo.InvariantCulture)
Select row).CopyToDataTable

  • AsEnumerable is used for bringing the rows into an enumerable sequence
  • There is no need to parseString into datetime (ParseExact Method) and then convert a datetime into a dateTime (Conver.toDate)

But this statement will not do any changes. the Let part stores the converted dateinfo as like a temporary variable, but will not not do any modifications. So the unedited row will be iterated (From In … is same like a for each iteration) and copy it to a datatable.

It looks like you tried to modifiy the datacolumn. This can be done in LINQ with converting and reconstructing the itemArray from row. The modified ItemArray can be used for adding a new row e.g. to an empty cloned datatable.

But updating column with a LINQ within an assign will not work.

Start to do it with a for each, check if the reconstruct the empty datatable approach will work for you. Last resort could be invoke code activity

1 Like