I'm extracting a date-formatted string (yyyy-MM-dd) and then converting it to a DateTime
and inserting it in the database using a storedprocedure. But I keep getting
System.Data.SqlTypes.SqlTypeException: SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.
The column in my table is of type date
.
I convert my string (e.g 2016-01-15
) by invoking DateTime.ParseExact(expirationDate, "yyyy-MM-dd", null)
and then I take that value and insert it as a parameter into my StoredProcedure and execute the proc.
But when using the debugger I can see that the return value is actually a yyyy-MM-dd HH:mm:ss
-formatted DateTime.
this is an example of how the code looks like
string expirationDate = GetDate();
DateTime date = DateTime.ParseExact(expirationDate, "yyyy-MM-dd", null);
ExecuteMyStoredProc(date);