Change data type of a multiple datacolumn using linq

Hello All,

I want to change multiple datacolumn data type through linq. As you can see in screen shot “start date” column i want to change in ‘dateTime’ datatype similar “Enddate” column change to ‘dateTime’ datatype and “Actual time” change to ‘time’ datatype and “ID” column to ‘int’. in these column null value can be present. please help to write exact query.

Demo (2).xlsx (8.8 KB)

Changing cell type / format on excel we can do with following activity

A direct change the datatype of a datacolumn from datatable after readin excel will lead to issues
(exception, value resets…) when the datacol values are already populated.

In such case we can do following:

  • defining a new empty datatable within the datacol structure (and needed configured datacol datatypes) e.g. with Build datatable / Api - dtNew
  • transfering the converted datavalues from dtOld to dtNew

Kindly note:

Datatype could be timespan. .Net does not offer a time datatype

Also we would recommend to define the case handling of missing dates like use null/nothing or a default date like 1900-01-01 etc.