aqDateTime.SetDateTimeElements Method

Applies to TestComplete 15.70, last modified on December 17, 2024

Description

Use the aqDateTime.SetDateTimeElements method to create a Date value with the specified year, month, day, hour, minute and second. To specify only the date portion, use the SetDateElements method. To specify only the time portion, use the SetTimeElements method.

Declaration

aqDateTime.SetDateTimeElements(Year, Month, Day, Hour, Min, Sec)

Year [in]    Required    Integer    
Month [in]    Required    Integer    
Day [in]    Required    Integer    
Hour [in]    Required    Integer    
Min [in]    Required    Integer    
Sec [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.

Hour

Specifies the desired hour.

Min

Specifies the desired minute.

Sec

Specifies the desired second.

Result Value

A Date/Time value that holds the specified date and time.

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
SetDateElements Method
SetTimeElements Method
Now Method
Today Method
Time Method

Highlight search results