SharePoint dates

You would like to think that SharePoint records the Creation and Modification dates for each item once only. Wrong!
Take a document in a document library. The item is seen as both an SPListItem and an SPFile. The created and modified dates are recorded separately for each. The actual item data is recorded in two SQL tables. That for the SPItem is recorded in the AllUserData table and that for the SPFile in the AllDocs table. A further complication is summer time adjustment. Depending upon how the item is referenced summer time adjustment may be necessary. Let’s take SPItem[SPbuiltInFieldId.Last_x0020_Modified]. This value is the same as the SPFile.TimeLastModified, that is, it is recorded in the same SQL table column. See the table below. When accessed via SPItem[SPbuiltInFieldId.Last_x0020_Modified] it should be time adjusted using the .ToLocalTime() function. The SPFile.TimeLastModified is already summer time adjusted.

SQL Column SP API Comment
[AllUserData].tp_Created item[SPBuiltInFieldId.Created]  
[AllUserData].tp_Modified item[SPBuiltInFieldId.Modified]  
[AllUserData].DateTime5 item["Expiration Date"]
item["_dlc_ExpireDate"]
Subject to Summer Time adjustment. Use .ToLocalTime()
[AllDocs].TimeCreated item.file.TimeCreated Subject to Summer Time adjustment.

Use .ToLocalTime()
This value is used by WebDav
item[SPBuiltInFieldId.Created_x0020_Date]
[AllDocs].TimeLastModified item.file.TimeLastModified Subject to Summer Time adjustment.
Use .ToLocalTime()
This value is used by WebDav
item[SPBuiltInFieldId.Last_x0020_Modified]  
[AllDocs].NextToLastTimeModified Not available
[AllDocs].MetainfoTimeLastModified Not available  
[AllDocs].LastWritten Not available
This entry was posted in SharePoint, SharePoint 2007, SharePoint 2010 and tagged , , . Bookmark the permalink.

Comments are closed.