SPAudit.DeleteEntries method

Deletes all audit events that occurred before the specified date and time from the SharePoint database.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Public Function DeleteEntries ( _
	deleteEndDate As DateTime _
) As Integer
Dim instance As SPAudit
Dim deleteEndDate As DateTime
Dim returnValue As Integer

returnValue = instance.DeleteEntries(deleteEndDate)


Type: System.DateTime

A DateTime representing the earliest date and time for which you want to preserve audit data.

Return value

Type: System.Int32
An Int32 that represents the number of audit entries that were deleted.


The calling code is in the context of a user who is not a site administrator.


The parent object that has this SPAudit object as the value of its Audit property is not an SPSite object.

Caution noteCaution

You may call object.Audit.DeleteEntries only when object is an SPSite object.

The deletion of audit entries is itself an audited event. A call to DeleteEntries creates an entry, and the method cannot delete the entry that it makes, so at least that one entry always exists in the database even if you attempt to delete all entries.

In Windows SharePoint Services 3.0, to delete all entries (except the entry described in the preceding paragraph) you cannot simply specify the current moment for deleteEndDate with Now. You must designate a future time. We recommend the following code, where mySiteCollection is a reference to an SPSite object.