I updated a list of mine by adding a column. After this update I receive the following error "Value does not fall within the expected range" when I try to get the data in the colum.
This is the code that I use to get the data:
private static DateTime GetModified(SPListItem item)
{
var field = item.Fields.GetFieldByInternalName("LastRevision");
if (!field.Hidden && item.Fields.ContainsFieldWithStaticName(field.StaticName)
&& item.GetFormattedValue(field.InternalName) != null)
{
return (DateTime)item[field.Id];
}
return DateTime.Parse(item["StartDate"].ToString());
}
I want show to you what happen with the Convert.ToDateTime too:
