0
DateTime sStartDate = DateTime.Parse(Convert.ToString(ViewState["StartDate"]));
                string sEndDate1 = Convert.ToString(ViewState["EndDate"]);
                DateTime sEndDate = DateTime.ParseExact(sEndDate1, "dd/MM/yyyy hh:mm:ss", CultureInfo.InvariantCulture);

After DateTime sEndDate its shows exception : string was not recognized as a valid datetime

1 Answers1

0

Change the format to dd/MM/yyyy HH:mm:ss:

DateTime.ParseExact(sEndDate1, "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture);

The hh format represents the hour as a number from 01 through 12.

If sEndDate1 hour is ie 13:00:00 it will throw an exception because it is out of range.

Jaqen H'ghar
  • 16,186
  • 8
  • 49
  • 52