visual studio eventlog1 query events by date/time or WMI query by date/time

Posted on 2010-09-15
Last Modified: 2012-05-10
I am using the WMI for the following:
Dim objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & myServer & "\root\cimv2")
            Dim colLoggedEvents = objWMIService.ExecQuery("Select * from Win32_NTLogEvent Where Logfile = '" & Me.cmbEventType.SelectedItem.ToString & "'")

This section below is commented out since I do not know what to use as a filer column
            'and TimeGenerated >='" & Me.dtFrom.ToString & "' and TimeGenerated <='" & Me.dtto.ToString & "'"

This section below is using vb studio 2010 and i do not know how to filter this either for a date/time range.

Me.EventLog1.MachineName = myServer
                'Me.EventLog1.Log = Me.cmbEventType.SelectedItem.ToString
                'myEventLogCount = Me.EventLog1.Entries.Count

                'For m = 0 To myEventLogCount

                '    myDate = Me.EventLog1.Entries.Item(m).TimeGenerated.Month & "/" & Me.EventLog1.Entries.Item(m).TimeGenerated.Day & "/" & Me.EventLog1.Entries.Item(m).TimeGenerated.Year
                '    myTime = Me.EventLog1.Entries.Item(m).TimeGenerated.Hour & ":" & Me.EventLog1.Entries.Item(m).TimeGenerated.Minute & ":" & Me.EventLog1.Entries.Item(m).TimeGenerated.Second
                '    mySource = Me.EventLog1.Entries.Item(m).Source
                '    myCategory = Me.EventLog1.Entries.Item(m).Category
                '    myEvent = Me.EventLog1.Entries.Item(m).EntryType
                '    myUser = Me.EventLog1.Entries.Item(m).UserName

Question by:mphillip85
  • 2
LVL 65

Accepted Solution

RobSampson earned 500 total points
ID: 33687689
Hi, the syntax for the date you need is


It's called UTC format:

This would hopefully help you convert your time to UTC in VB.NET:



Author Closing Comment

ID: 33697431
this is what i needed.
LVL 65

Expert Comment

ID: 33697441
Thanks for the grade.  I'm not that familiar with .NET....would you mind posting the line(s) of code that you used to convert your input box dates to UTC?



Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now