SWbemDateTime.SetVarDate method

The SetVarDate method of the SWbemDateTime object converts a date in the VT_DATE format to the CIM datetime format.

A VT_DATE value is a variant datetime value that Visual Basic and ActiveX use.

For an explanation of this syntax, see Document Conventions for the Scripting API.


SWbemDateTime.SetVarDate( _
  ByVal vdate, _
  [ ByVal bIsLocal ] _


vdate [in]

The variant date value to set the object. This parameter must be in the VT_DATE format.

bIsLocal [in, optional]

If TRUE, vdate is interpreted as a local time, and the Coordinated Universal Time (UTC) property contains the local time that is converted to the correct UTC offset. When bIsLocal is FALSE, then vdate is converted directly into a UTC value with an offset of zero (0).

Return value

This method does not return a value.

Error codes

After completing the SetVarDate method, the Err object may contain the error code in the following table.

2147749921 (0x80041021)

The format of vdate is not valid.


After a successful call to SetVarDate, the DATETIME value is interpreted as an absolute datetime value instead of an interval, and the IsInterval property is set to FALSE.

The intrinsic Visual Basic or VBScript function CDate provides a datetime value in the VT_DATE format for input to SetVarDate.


For examples of using the SWbemDateTime object to convert CIM DATETIME values to and from either the FILETIME format or the VT_DATE format, see WMI Tasks: Dates and Times. For a description of the CIM DATETIME format, see Date and Time Format.

The Convert Date to WMI Date-Time Format VBScript code sample in the TechNet Gallery uses SetVarDate to convert a regular date-time value into the UTC date-time format.


Minimum supported client

Windows Vista

Minimum supported server

Windows Server 2003

Type library




See also




© 2015 Microsoft