All WMI queries that give or take datetime values, do so in a certain format called CIM_DATETIME. For scripting guys, this is only a minor inconvenience. The following listing is the entire code to display the OS install date in various formats:
' Create a new datetime object.
Set dateTime = CreateObject("WbemScripting.SWbemDateTime")
' Retrieve a WMI object that contains a datetime value.
for each os in GetObject( _
"winmgmts:").InstancesOf ("Win32_OperatingSystem")
' The InstallDate property is a CIM_DATETIME.
MsgBox os.InstallDate
dateTime.Value = os.InstallDate
' Display the year of installation.
MsgBox "This OS was installed in the year " & dateTime.Year
' Display the installation date using the VT_DATE format.
MsgBox "Full installation date (VT_DATE format) is " _
& dateTime.GetVarDate
' Display the installation date using the FILETIME format.
MsgBox "Full installation date (FILETIME format) is " _
& dateTime.GetFileTime
next
Set datetime = Nothing
For the native coders among us, the standard Win32 time functions neither produce nor consume this format meaning we have to perform some jiggery poker to get it to play nice.
Read the rest on Just Let It Flow