I have a Nullable DateTime
, and I got an error :
Additional information: String was not recognized as a valid DateTime.
I looked at here, here,here and also here . I also tried String.Format("{0:s}", dateTime)
, but it does not change my DateTime
format.My code is like below,
if (person.JsonData.PasswordChangeRequestTime != null)
{
DateTime data;
data = DateTime.ParseExact(((DateTime)person.JsonData.PasswordChangeRequestTime).Date.ToStringDateTime(), "dd'-'MM'-'yyyy HH':'mm':'ss", CultureInfo.InvariantCulture);
person.setColumnValue("passwordchangerequesttime", data);
}
One of my DateTime
is like this:
1/1/2015 2:00:00 PM
I want them in a format of
1-1-2015 14:00:00
what is wrong with my DateTime.ParseExact
function?
By the way, I do not want to use subString
function!