I import data from a CSV file into a datatable.
Existing vendors send period as '201901' in one column. A new vendor sends period as 2 columns like year '2019' and month 'JAN'.
I want to combine the 2 columns into '201901' so that the rest of the code logic works as earlier.
When I looked at the documentation for Datatable.Columns.Add
, I see all the examples are just numeric expressions only, nothing related to string or dates in the column expressions.
Here is my Code.. These are from CSV file so when imported to datatable, these columns have 2019 and JAN data.
DT.Columns.Add("MAT_YEAR", typeof(string));
DT.Columns.Add("MAT_MONTH", typeof(string));
I want to get the computed value based on above 2 columns
DT.Columns.Add("MONTHNUM", typeof(int),"DateTime.ParseExact(MAT_MONTH,\"MMM\",null).Month");
DT.Columns.Add("MAT_PERIOD", typeof(string), "MAT_YEAR + Convert.ToString(MONTHNUM)");
I am getting error on DateTime.Parse
How can I create computed columns in Datatable based on string or dates?