aqDateTime.SetDateElements Method

Applies to TestComplete 15.42, last modified on September 08, 2022

Description

Use the aqDateTime.SetDateElements method to create a Date value with the specified year, month and day. The resulting value has only the date portion. To specify both the date and time elements, use the SetDateTimeElements method. To specify only the time portion, use the SetTimeElements method.

Declaration

aqDateTime.SetDateElements(Year, Month, Day)

Year [in]    Required    Integer    
Month [in]    Required    Integer    
Day [in]    Required    Integer    
Result Date/Time

Applies To

The method is applied to the following object:

Parameters

The method has the following parameters:

Year

Specifies the desired year.

Month

Specifies the number of the desired month.

Day

Specifies the desired day of the month.

Result Value

A Date/Time value that holds the specified date.

Example

The code below demonstrates how you can set a new system date and/or time.

JavaScript, JScript

function SettingNewSystemDateTime()
{
  var dt1 = aqDateTime.SetDateTimeElements(2010, 6, 22, 10, 15, 12);
  var dt2 = aqDateTime.SetDateElements(2010, 6, 22);
  var time1 = aqDateTime.SetTimeElements(10, 15, 12);

  // Set a new system date
  aqDateTime.SetSystemDateTime(dt2);
  // Set new system time
  aqDateTime.SetSystemDateTime(time1);
  // -- or --
  // Set a new system date and time using one function
  aqDateTime.SetSystemDateTime(dt1);

  // Post the current date and time to the test log
  var dt = aqDateTime.Now();
  Log.Message(dt);
}

Python

def SettingNewSystemDateTime():
  dt1 = aqDateTime.SetDateTimeElements(2010, 6, 22, 10, 15, 12)
  dt2 = aqDateTime.SetDateElements(2010, 6, 22)
  time1 = aqDateTime.SetTimeElements(10, 15, 12)
  # Set a new system date
  aqDateTime.SetSystemDateTime(dt2)
  # Set new system time
  aqDateTime.SetSystemDateTime(time1)
  # --or--
  # Set a new system date and time using one function
  aqDateTime.SetSystemDateTime(dt1)
  # Post the current date and time to the test log
  dt = aqDateTime.Now()
  Log.Message(dt)

VBScript

Sub SettingNewSystemDateTime
  Dim dt1, dt2, time1, dt

  dt1 = aqDateTime.SetDateTimeElements(2010, 6, 22, 10, 15, 12)
  dt2 = aqDateTime.SetDateElements(2010, 6, 22)
  time1 = aqDateTime.SetTimeElements(10, 15, 12)

  ' Set a new system date
  aqDateTime.SetSystemDateTime dt2
  ' Set new system time
  aqDateTime.SetSystemDateTime time1
  ' -- or --
  ' Set a new system date and time using one function
  aqDateTime.SetSystemDateTime dt1

  ' Post the current date and time to the test log
  dt = aqDateTime.Now
  Log.Message dt
End Sub

DelphiScript

procedure SettingNewSystemDateTime;
var dt1, dt2, time1, dt: OleVariant;
begin
  dt1 := aqDateTime.SetDateTimeElements(2010, 6, 22, 10, 15, 12);
  dt2 := aqDateTime.SetDateElements(2010, 6, 22);
  time1 := aqDateTime.SetTimeElements(10, 15, 12);

  // Set a new system date
  aqDateTime.SetSystemDateTime(dt2);
  // Set new system time
  aqDateTime.SetSystemDateTime(time1);
  // -- or --
  // Set a new system date and time using one function
  aqDateTime.SetSystemDateTime(dt1);

  // Post the current date and time to the test log
  dt := aqDateTime.Now;
  Log.Message(dt);
end;

C++Script, C#Script

function SettingNewSystemDateTime()
{
  var dt1 = aqDateTime["SetDateTimeElements"](2010, 6, 22, 10, 15, 12);
  var dt2 = aqDateTime["SetDateElements"](2010, 6, 22);
  var time1 = aqDateTime["SetTimeElements"](10, 15, 12);

  // Set a new system date
  aqDateTime["SetSystemDateTime"](dt2);
  // Set new system time
  aqDateTime["SetSystemDateTime"](time1);
  // -- or --
  // Set a new system date and time
  aqDateTime["SetSystemDateTime"](dt1);

  // Post the current date and time to the test log
  var dt = aqDateTime["Now"]();
  Log.Message(dt);
}

See Also

Working With Dates
Working With Time
SetDateTimeElements Method
SetTimeElements Method
Now Method
Today Method
Time Method

Highlight search results