title: Comparing WMI DateTime to String in Query
body: <p>I'm trying to query Win32_NTLogEvent for entries past the previous time that I ran the query. I've tried using a string variable so that I can change it every time I run the script. But I am getting a null returned for the generated collection. I've looked up what I can about WMI DateTimes and using them in comparisons. Although I have found some seemingly conflicting information (namely some sources using human readable to compare directly with UTC and others not). I've tried a UTC string and a human readable string. But neither seem to work. I'm thinking it is because I need to compare a datetime to a datetime as opposed to a string to a string. Although many sources seem to say that a string to a string would work in this case. But, even if I am right, I'm not sure how to convert the time for every object in Win32_NTLogEvent while inside the query.</p>
  
  <p>Here is the relevant part of my script. The UTC that is commented out is just there because I don't want to retype the date if I have to go back to UTC:</p>
  
  <pre><code>strTimeMin = "01/01/1970/0:00:00"
  '19700101000000.000000-480
  Set objWMIService = GetObject("winmgmts:" _
   &amp; "{impersonationLevel=impersonate}!\\" &amp; strComputer &amp; "\root\cimv2")
  
  'Querying Event Logs
  
  Set colLoggedEvents = objWMIService.ExecQuery _
   ("SELECT * FROM Win32_NTLogEvent WHERE Logfile = 'system' AND "_
   &amp; "Type = 'Error' AND TimeGenerated &gt; " &amp; strTimeMin &amp; "")
  </code></pre>
  
  <p>Thanks for any help!</p>