SqlBulkCopy - New DataColumn combining date and time columns

Viewed 16

In my DataTable, I have a column for the date (Fecha) and a column for the time (Hora) such as:

   Fecha      Hora
15-01-2022    12.35

I would like to add a new DataColumn which would combine date and time in order to obtain something like: 15-01-2022 12:35:00.

In C#, it would be quite simple, something like:

var resultDateTime= record.Fecha.Add(new TimeSpan(Convert.ToInt32(record.Hora.Split('.')[0]), Convert.ToInt32(record.Hora.Right(2)), 0))

But I am struggling with the expression for the DataColumn to obtain the same result:

                        var dcDateTime = new DataColumn();
                        dcDateTime.DataType = typeof(System.DateTime);
                        dcDateTime.ColumnName = "Date_Time";
                        dcDateTime.Expression = @"...";
                        dt.Columns.Add(dcDateTime);

Any idea on how do it?

0 Answers
Related