Category Archive: Date and Time

Apr 01 2008

Determine the Name of the Time Zone in which a Computer is Running

Use the Win32_TimeZone class and check the value of the Description property. Set wmiService = GetObject( “Winmgmts:root\cimv2″ ) Set items = wmiService.ExecQuery( “Select * from Win32_TimeZone” ) For Each item in items Print “Description: ” & item.Description Print “Daylight Name: ” & item.DaylightName Print “Standard Name: ” & item.StandardName Next

Apr 01 2008

Convert WMI Dates to Standard Dates and Times

To convert WMI dates to FILETIME or VT_DATE format or to parse the date into component year, month, day, hours, and so on, you must write your own code. Set dtmInstallDate = CreateObject( “WbemScripting.SWbemDateTime” ) Set wmiService = GetObject( “Winmgmts:root\cimv2″ ) Set os = wmiService.ExecQuery( “Select * from Win32_OperatingSystem” ) For Each itemOS in os …

Continue reading »

Mar 31 2008

Determine the Day of the Week

Dot.Net Framework provides several classes for dates and times. the primary class is the System.DateTime. The class Represents an instant in time, typically expressed as a date and time of day. The System.DayOfWeek enumeration Specifies the day of the week. Friday Indicates Friday. Monday Indicates Monday. Saturday Indicates Saturday. Sunday Indicates Sunday. Thursday Indicates Thursday. …

Continue reading »

Mar 31 2008

Determine the Day of the Week

VBScript has a built-in function called DatePart that can take any date you give it and tell you everything from the hour to the minute to the day of the week. All you have to do is pass DatePart two items: item Description The date part you’re looking for. In this case, we’re looking for …

Continue reading »

Mar 31 2008

Tomorrow and Yesterday’s Dates

what if you want to retrieve today’s date? MsgBox Date() But what about yesterday’s date? it’s just as easy to determine yesterday’s date as it is today’s date. That’s because VBScript can do date arithmetic: give it today’s date, and then you can simply subtract 1 day to determine yesterday’s date. In other words: MsgBox …

Continue reading »