Applies to TestComplete 14.20, last modified on September 11, 2019

Description

The aqDateTime object provides unified methods for working with date and time values.

Members

Example

The example below demonstrates how you can calculate the time interval between two date values.

JavaScript, JScript

function TimeIntervalDemo()
{
  var Time1 = aqDateTime.Time();
  var Time2 = aqDateTime.AddTime(Time1,1,0,0,5);
  var Difference = aqDateTime.TimeInterval(Time1, Time2);
  Log.Message("The interval as DateTime: " + aqConvert.DateTimeToStr(Difference));
  // Posts "The interval as DateTime: 12/31/1899 12:00:05 AM"
  Log.Message("The interval in Days:Hours:Minutes:Seconds format: " + aqConvert.TimeIntervalToStr (Difference));
  // Posts "The interval in Days:Hours:Minutes:Seconds format: 1:00:00:05"
}

Python

def TimeIntervalDemo():
  Time1 = aqDateTime.Time()
  Time2 = aqDateTime.AddTime(Time1,1,0,0,5)
  Difference = aqDateTime.TimeInterval(Time1, Time2)
  Log.Message("The interval as DateTime: " + aqConvert.DateTimeToStr(Difference))
  # Posts "The interval as DateTime: 12/31/1899 12:00:05 AM"
  Log.Message("The interval in Days:Hours:Minutes:Seconds format: " + aqConvert.TimeIntervalToStr (Difference))
  # Posts "The interval in Days:Hours:Minutes:Seconds format: 1:00:00:05"

VBScript

Sub TimeIntervalDemo
Dim Time1, Time2, Difference
  Time1 = aqDateTime.Time()
  Time2 = aqDateTime.AddTime(Time1,1,0,0,5)
  Difference = aqDateTime.TimeInterval(Time1, Time2)
  Log.Message("The interval as DateTime: " + aqConvert.DateTimeToStr(Difference))
  ' Posts "The interval as DateTime: 12/31/1899 12:00:05 AM"
  Log.Message("The interval in Days:Hours:Minutes:Seconds format: " + aqConvert.TimeIntervalToStr (Difference))
  ' Posts "The interval in Days:Hours:Minutes:Seconds format: 1:00:00:05"
End Sub

DelphiScript

procedure TimeIntervalDemo;
var Time1, Time2, Difference;
begin
  Time1 := aqDateTime.Time();
  Time2 := aqDateTime.AddTime(Time1,1,0,0,5);
  Difference := aqDateTime.TimeInterval(Time1, Time2);
  Log.Message('The interval as DateTime: ' + aqConvert.DateTimeToStr(Difference));
  // Posts "The interval as DateTime: 12/31/1899 12:00:05 AM"
  Log.Message('The interval in Days:Hours:Minutes:Seconds format: ' + aqConvert.TimeIntervalToStr (Difference));
  // Posts "The interval in Days:Hours:Minutes:Seconds format: 1:00:00:05"
end;

C++Script, C#Script

function TimeIntervalDemo()
{
  var Time1 = aqDateTime["Time"]();
  var Time2 = aqDateTime["AddTime"](Time1,1,0,0,5);
  var Difference = aqDateTime["TimeInterval"](Time1, Time2);
  Log["Message"]("The interval as DateTime: " + aqConvert["DateTimeToStr"](Difference));
  // Posts "The interval as DateTime: 12/31/1899 12:00:05 AM"
  Log["Message"]("The interval in Days:Hours:Minutes:Seconds format: " + aqConvert["TimeIntervalToStr"](Difference));
  // Posts "The interval in Days:Hours:Minutes:Seconds format: 1:00:00:05"
}

See Also

TestComplete Helper Objects
Working With Dates
Working With Time
aqConvert Object
aqEnvironment Object
aqFile Object
aqFileSystem Object
aqObject Object
aqString Object
aqUtils Object

Highlight search results