EventLogQuery uses the XML format to query the event log. You can find the schema for the XML request here .
Text Select Element - An XPath expression calculated against serializing XML events.
You can find the schema for the XML event here .
The TimeCreated element has a SystemTime attribute of type dateTime , so the format of this (in your XML request) is what the XPath processor can parse as a valid dateTime (see 3.2.7.1. Lexical representation for specifics).
For example, you can try this query:
<QueryList> <Query Id="0" Path="Application"> <Select Path="Application">*[System[TimeCreated[@SystemTime = '2011-12-20T00:42:53.000000000Z']]]</Select> </Query> </QueryList>
Which parses and returns a value if you have an event that was generated exactly on the given date and time.
Also dateDiff is a Filter XPath protocol extension function that takes one or two SYSTEMTIME arguments and returns a number, so just use the number in the expression using this function (as in your example).
PS You can use the Windows event viewer ( %windir%\system32\eventvwr.msc ) to enter and quickly evaluate the XML query XML to create custom views (Windows Vista, 7 and 2008). only):

Samu lang
source share