sharepoint-2007last-modifiedsplist

How to get the last modified date of a SharePoint list (SPList)


I have some code which replicates list templates files for new sites in SharePoint 2007. It checks the SPList.LastItemModified to see if there are news entries in order to know whether or not to create a new .STP file.

What I would like though to also be able to see if the list was modified, for example the views and columns, etc.

Can anyone help me out with this? Thank you.


Solution

  • It looks like SPList.LastItemModifiedDate is the value that you want.

    According to MSDN:

    Gets the date and time that an item, field, or property of the list was last modified.

    (emphasis mine)

    So it is more than just the last item modified, it is the last time the list was modified.

    In order to confirm, I looked at a list that, according to All Site Content, was last modified 4 hours ago (the list is updated each night by a timer job). However, the greatest modified date of any list item was 15 hours ago. I then looked at viewlsts.aspx to see how Last Modified is calculated on the All Site Content page and found the following:

    SPUtility.TimeDeltaAsString(spList.LastItemModifiedDate, dtCurrent)
    

    So I would use SPList.LastItemModifiedDate to determine the last time the list was modified, but it is not reliable for retrieving the date of the last list item modified.