Ramco Ramco

Ramco Ramco

  • 441
  • 3.4k
  • 523k

String not recognized as a valid date time

Mar 31 2023 7:58 AM

Hi

 On below line i am getting above error

DateTime StartDate = DateTime.ParseExact(vDT1, "dd-MM-yyyy HH:mm", System.Globalization.CultureInfo.InvariantCulture);

In vTime value is "15:15"

In vDt1 it is showing wrong value - 15/04/2023 00:00:00 15:15 it should be 15/04/2023 15:15:00 i think so

String vTime = Convert.ToDateTime(colum.SessionStartTime).ToString("HH") + ":" + Convert.ToDateTime(colum.SessionStartTime).ToString("mm");
                        String vDT1 = Convert.ToDateTime(Rec.SessionDate).AddDays(7 * Convert.ToInt32(ddlPush.SelectedValue)) + " " + vTime;
                        DateTime StartDate = DateTime.ParseExact(vDT1, "dd-MM-yyyy HH:mm", System.Globalization.CultureInfo.InvariantCulture);

Value in Database is : 2023-04-01 15:15:00.000

Thanks


Answers (2)