Hi,
I am trying to read an excel range to a datatable and convert one of the Column value from String to DateTime type. My objective is to get the column format to match by SQL Server Table column datatype.
I tried-
- Convert.ToDateTime(DateTime.ParseExact(row.Item(3).ToString,“dd-MM-yyyy hh:mm:ss”,System.Globalization.CultureInfo.InvariantCulture).ToString(“YYYY-MM-DD hh:mm:ss.nnn”)
- DateTime.ParseExact(row.Item(3).ToString,“dd-MM-yyyy hh:mm:ss”,System.Globalization.CultureInfo.InvariantCulture)
- Convert.ToDateTime(row.item(3).ToString)
My Excel Cell value is in “dd-MM-yyyy hh:mm AM/PM” format and i want it to convert to “YYYY-MM-DD hh:mm:ss.nnn”