I've been working on this problem to find WSS sites that haven't been used for more then three months. SPWeb has a property called LastItemModifiedDate, to get the date when the last item in the SPWeb has been changed. However, the LastItemModifiedDate property applies only to sites returned by using one of the GetSubwebsForCurrentUser methods of the SPWeb class. Ok, but what if you want to get it from the rootweb?
Thanks to Tariq, he came up with the solution about using SPSite and the LastContentModifiedDate property:
SPGlobalAdmin globalAdmin = new SPGlobalAdmin();
SPVirtualServerCollection vServers = globalAdmin.VirtualServers;
foreach (SPVirtualServer vs in vServers)
{
foreach (SPSite site in vs.Sites)
{
Console.WriteLine(site.Url);
Console.WriteLine(site.LastContentModifiedDate);
}
}
This should do it :)