Tuesday, September 22, 2015

Parsing ISO date (string) to System DateTime


This did not work (did not parse and all values came out the minimu values):

DateTime dt = DateTime.MinValue;

DateTime.TryParse(item.Fields[ILogbookArticleEntryConstants.EntryDateFieldId].Value, out dt);

Do this:

DateTime dt = DateUtil.IsoDateToDateTime(item.Fields[ILogbookArticleEntryConstants.EntryDateFieldId].Value, DateTime.MinValue);

No comments:

Post a Comment