Jagjit Saini

Jagjit Saini

  • NA
  • 196
  • 37.9k

String was not recognized as a valid DateTime format

Mar 27 2022 10:03 AM

Hi

  I am trying to upload data but it is giving above error

DateTime StartTime = DateTime.Now;String Time = colum[2].ToString();String DT1 = colum[1].ToString() + " " + Time;DateTime StartDate = DateTime.ParseExact(DT1, "dd-MM-yyyy HH:mm", System.Globalization.CultureInfo.InvariantCulture);StartTime = Convert.ToDateTime(StartDate.ToString("yyyy-MM-dd HH:mm"));

Below is the Excel Data

col1 Col2 Col3
13 01/04/2022 14:30
18 02/04/2022 16:00
13 03/04/2022 17:15

Thanks


Answers (6)