Re: SWbemDateTime to Win 2k Compatible



I don't find information on a TimeGenerated property, but the TimeWritten
property of event logs is in UTC in the form:

yyyymmddHHMMSS.xxxxx-UUU

where:

yyyy is the year
mm is the month
dd is the day
HH is the hour
MM the minute
SS the second
xxxxxx milliseconds
UUU is number of minutes to subtract from current time to get UTC.

The TimeWritten property is not an Integer8 value, but a generalized
date/time format. To get logs written in the last two hours (accurate to
within one second) you could use code similar to:
============
' Get current date/time less 2 hours.
dtmStart = DateAdd("h", -2, Now())

' Convert to generalized date/time format.
strValue = CStr(Year(dtmStart)) _
& Right("0" & CStr(Month(dtmStart)), 2) _
& Right("0" & CStr(Day(dtmStart)), 2) _
& Right("0" & CStr(Hour(dtmStart)), 2) _
& Right("0" & CStr(Minute(dtmStart)), 2) _
& Right("0" & CStr(Second(dtmStart)), 2) _
& ".000000-480"
========
This assumes your time zone bias is -480 minutes. This value can be used in
the WMI query for event logs.

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--

"Viper640" <pat@xxxxxxxxxx> wrote in message
news:32904264-6730-4CFE-BFBD-BD9817B15021@xxxxxxxxxxxxxxxx
they might help me a little, but if i convert the dates to integers will
the
wmi query recognize them as date time values or integers?

the end result is to get two values to input into the wmi query so i can
restrict the output of events to a few hours worth. the SWbemDateTime
function i used in the last script doosn't work on win 2k, so i need
another
method to compute the two dates. if converting them to integers will help
im
all for it but if the WMI wont accept them then i would need something
else.

thanks for all your help i will see if these help me. if anyone has other
ideas feel free to list them. thanks again!
--
Patrick Roye
Managed Services Dept.
Main Street Software, Inc.


"Richard Mueller [MVP]" wrote:

The SWbemDateTime object is not available in Windows 2000. It's a bit
hard
to tell what you are doing, but if you need to convert the current time
in
the local time zone to an Integer8 value in UTC, perhaps you can use this
VBScript example:

http://www.rlmueller.net/Programs/DateToInteger8.txt

The local time zone bias is read from the local registry. Any specifed
date/time value in the current time zone is converted to the
corresponding
Integer8 (64-bit) value in UTC.

Another method would be to use the w32tm.exe utility, but this also is
not
available on W2k. If you need to do the reverse (convert an Integer8
value
to a date/time in the current time zone), see this example:

http://www.rlmueller.net/Programs/Integer8Date.txt

--
Richard Mueller
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net
--




.



Relevant Pages

  • Re: SWbemDateTime to Win 2k Compatible
    ... The TimeWritten property is not an Integer8 value, ... ' Get current date/time less 2 hours. ... This assumes your time zone bias is -480 minutes. ... the WMI query for event logs. ...
    (microsoft.public.scripting.vbscript)
  • Re: Question about ISO8601 vs. strftime()
    ... online references to ISO8601 just get it wrong? ... that link only shows the form with the UTC ... but not the offset as far as I can tell. ... assumed to be in some local time zone. ...
    (comp.programming)
  • Re: Time Zones as politics
    ... be in a different time zone from his arch-rival, ... we are not permitted to criticize him in any way because after ... UTC +5 AKA Eastern Standard Time. ... Soon upon the establishment of the Greenwhich Meridian as the time ...
    (alt.horology)
  • Re: Received mail timestamp is off by 7 hours
    ... It should be one hour ahead of UTC right now. ... Notice that the timestamp on your local e-mail server corresponds to ... the CMOS real-time clock should be set to ... UTC and fix your time zone to match your location. ...
    (freebsd-questions)
  • Re: xsd:dateTime and sqltypes:datetime validations differ. Any idea why? Please help.
    ... I would stick with the XSD data types personally. ... If you wanted to store "date/time" type data without ... Another interesting feature of SQL 2005 xs:dateTime support is that all ... date/time values are converted and stored as UTC time (time zone Z). ...
    (microsoft.public.sqlserver.xml)