No overload for method 'ToString" takes 1 arguments when casting date
You want to use DateTime.ToString(format)
not Nullable<DateTime>.ToString(no overload)
:
DateTime? myDate = form.dteStartDate;string sqlFormattedDate = myDate.Value.ToString("yyyy-MM-dd HH:mm:ss");
Of course this doesn't handle the case that there is no value. Perhaps something like this:
string sqlFormattedDate = myDate.HasValue ? myDate.Value.ToString("yyyy-MM-dd HH:mm:ss") : "<not available>";