aqDateTime.Compare Method

Applies to TestComplete 15.40, last modified on March 25, 2022

Description

The aqDateTime.Compare method compares two Date/Time values.

Declaration

aqDateTime.Compare(Date1, Date2)

Date1 [in]    Required    Date/Time    
Date2 [in]    Required    Date/Time    
Result Integer

Applies To

The method is applied to the following object:

Parameters

The method has the following parameters:

Date1

The Date/Time value to be compared.

Date2

The Date/Time value to be compared.

Result Value

An integer number that indicates the comparison result. The possible values are:

-1 Date1 is earlier than Date2
0 Date1 is equal to Date2
1 Date1 is later than Date2

Remarks

To compare Date/Time values, this method uses the date and time formats specified by the current locale setting of Windows. If the values are specified in a format different from the current locale format, the method may return incorrect results.

Example

The code below demonstrates how you can use the Compare method in your script:

JavaScript, JScript

function ComparingDates()
{
  var dateTimeTimeout = aqDateTime.AddSeconds(aqDateTime.Now(), 15);
    
  while (aqDateTime.Compare(aqDateTime.Now(), dateTimeTimeout) < 1)
  {
    Delay(500);
  }
  
}

Python

def ComparingDates():
  dateTimeTimeout = aqDateTime.AddSeconds(aqDateTime.Now(), 15)
  while (aqDateTime.Compare(aqDateTime.Now(), dateTimeTimeout) < 1):
    Delay(500)

VBScript

Sub ComparingDates
  Dim dateTimeTimeout
  
  dateTimeTimeout = aqDateTime.AddSeconds(aqDateTime.Now(), 15)
  While aqDateTime.Compare(aqDateTime.Now(), dateTimeTimeout) < 1
    Delay(500)
  WEnd
  
End Sub

DelphiScript

procedure ComparingDates();
var dateTimeTimeout;
begin
 dateTimeTimeout := aqDateTime.AddSeconds(aqDateTime.Now(), 15);
    
  while (aqDateTime.Compare(aqDateTime.Now(), dateTimeTimeout) < 1) do
  begin
    Delay(500);
  end;
  
end;

C++Script, C#Script

function ComparingDates()
{
  var dateTimeTimeout = aqDateTime["AddSeconds"](aqDateTime["Now"](), 15);
    
  while (aqDateTime["Compare"](aqDateTime["Now"](), dateTimeTimeout) < 1)
  {
    Delay(500);
  }
  
};

See Also

Working With Dates
Working With Time
TimeInterval Method

Highlight search results