Export (0) Print
Expand All

Audit.CreateDate Property

Gets the date and time when the audit log was created.

Namespace:  Microsoft.SqlServer.Management.Smo
Assembly:  Microsoft.SqlServer.Smo (in Microsoft.SqlServer.Smo.dll)

public DateTime CreateDate { get; }

Property Value

Type: DateTime
A DateTime system object value that specifies the time and date when the audit log was created.

The following code example demonstrates how to get the date and time when the audit log was created and display that information on the console.


using System;

using Microsoft.SqlServer.Management.Smo;

namespace samples


class Program


static void Main(string[] args)


//Create the audit

Server dbServer = new Server("(local)");

Audit dbAudit = new Audit(dbServer, "Test Audit");

            dbAudit.DestinationType = AuditDestinationType.File;
            dbAudit.FilePath = "C:\\AuditDirectory";


//Get the audit date and display it on the console

DateTime auditDate = dbAudit.CreateDate;

Console.WriteLine("The audit began at " +






#Create the audit
$dbServer = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")
$dbAudit = New-Object Microsoft.SqlServer.Management.Smo.Audit($dbServer, "Test Audit")
$dbAudit.DestinationType = [Microsoft.SqlServer.Management.Smo.AuditDestinationType]'File'
$dbAudit.FilePath = "C:\AuditDirectory"

#Get the audit date and display it
Write-Host "The audit began at" $dbAudit.CreateDate
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

© 2015 Microsoft