private string GetFieldValue(SPField field, SPListItemVersion version) { string fieldValue = string.Empty; SPFieldType fieldType = field.Type; switch (fieldType) { case SPFieldType.Lookup: SPFieldLookup newField = (SPFieldLookup)field; fieldValue = newField.GetFieldValueAsText(version[field.StaticName]); break; case SPFieldType.User: SPFieldUser newUser = (SPFieldUser)field; fieldValue = newUser.GetFieldValueAsText(version[field.StaticName]); break; case SPFieldType.ModStat: SPFieldModStat modStat = (SPFieldModStat)field; fieldValue = modStat.GetFieldValueAsText(version[field.StaticName]); break; case SPFieldType.URL: SPFieldUrl urlField = (SPFieldUrl)field; fieldValue = urlField.GetFieldValueAsHtml(version[field.StaticName]); break; case SPFieldType.DateTime: SPFieldDateTime newDateField = (SPFieldDateTime)field; if (!string.IsNullOrEmpty(newDateField.GetFieldValueAsText(version[field.StaticName]))) { if (newDateField.DisplayFormat == SPDateTimeFieldFormatType.DateTime) { fieldValue = DateTime.Parse(newDateField.GetFieldValueAsText(version[field.StaticName])).ToString(); } else { fieldValue = DateTime.Parse(newDateField.GetFieldValueAsText(version[field.StaticName])).ToShortDateString(); } } break; case SPFieldType.Invalid: // http://sharepointnadeem.blogspot.com/2013/09/sharepoint-spfieldtype-is-invalid-for.html if (field.TypeAsString.Equals("TaxonomyFieldType") || field.TypeAsString.Equals("TaxonomyFieldTypeMulti")) { TaxonomyField taxonomyField = field as TaxonomyField; fieldValue = taxonomyField.GetFieldValueAsText(version[field.StaticName]); } else { fieldValue = version[field.StaticName].ToString(); } break; default: fieldValue = version[field.StaticName].ToString(); break; } return(fieldValue); }