aqDateTime.AddSeconds Method

Applies to TestComplete 14.61, last modified on April 22, 2021

Description

The aqDateTime.AddSeconds method adds or subtracts the specified number of seconds to (from) the specified Date/Time value and returns the resultant date/time.

Declaration

aqDateTime.AddSeconds(InputDateSeconds)

InputDate [in]    Required    Date/Time    
Seconds [in]    Required    Integer    
Result Date/Time

Applies To

The method is applied to the following object:

Parameters

The method has the following parameters:

InputDate

Specifies the original date and time.

Seconds

Specifies the number of seconds to change. If Seconds is positive, then the given number is added. If Seconds is negative, then the given number is subtracted.

Result Value

The value of the Date/Time type that is earlier or later than InputDate by the number of seconds specified.

Example

The code below demonstrates how you can change a date and/or time by adding some values to it.

JavaScript, JScript

function ChangingTime()
{
  var Time1, Time2, Time3, Time4, Time5, Time6, Time7;

  Time1 = aqDateTime.Now();
  Time2 = aqDateTime.AddDays(Time1, 5);
  Time3 = aqDateTime.AddHours(Time1, 7);
  Time4 = aqDateTime.AddMinutes(Time1, 24);
  Time5 = aqDateTime.AddMonths(Time1, 2);
  Time6 = aqDateTime.AddSeconds(Time1, 15);
  Time7 = aqDateTime.AddTime(Time1, 9, 3, 24, 51);

  Log.Message(aqConvert.DateTimeToStr(Time1));
  Log.Message(aqConvert.DateTimeToStr(Time2));
  Log.Message(aqConvert.DateTimeToStr(Time3));
  Log.Message(aqConvert.DateTimeToStr(Time4));
  Log.Message(aqConvert.DateTimeToStr(Time5));
  Log.Message(aqConvert.DateTimeToStr(Time6));
  Log.Message(aqConvert.DateTimeToStr(Time7));
}

Python

def ChangingTime():
  Time1 = aqDateTime.Now()
  Time2 = aqDateTime.AddDays(Time1, 5)
  Time3 = aqDateTime.AddHours(Time1, 7)
  Time4 = aqDateTime.AddMinutes(Time1, 24)
  Time5 = aqDateTime.AddMonths(Time1, 2)
  Time6 = aqDateTime.AddSeconds(Time1, 15)
  Time7 = aqDateTime.AddTime(Time1, 9, 3, 24, 51)
  
  Log.Message(aqConvert.DateTimeToStr(Time1))
  Log.Message(aqConvert.DateTimeToStr(Time2))
  Log.Message(aqConvert.DateTimeToStr(Time3))
  Log.Message(aqConvert.DateTimeToStr(Time4))
  Log.Message(aqConvert.DateTimeToStr(Time5))
  Log.Message(aqConvert.DateTimeToStr(Time6))
  Log.Message(aqConvert.DateTimeToStr(Time7))

VBScript

Sub ChangingTime
  Dim Time1, Time2, Time3, Time4, Time5, Time6, Time7

  Time1 = aqDateTime.Now
  Time2 = aqDateTime.AddDays(Time1, 5)
  Time3 = aqDateTime.AddHours(Time1, 7)
  Time4 = aqDateTime.AddMinutes(Time1, 24)
  Time5 = aqDateTime.AddMonths(Time1, 2)
  Time6 = aqDateTime.AddSeconds(Time1, 15)
  Time7 = aqDateTime.AddTime(Time1, 9, 3, 24, 51)

  Log.Message aqConvert.DateTimeToStr(Time1)
  Log.Message aqConvert.DateTimeToStr(Time2)
  Log.Message aqConvert.DateTimeToStr(Time3)
  Log.Message aqConvert.DateTimeToStr(Time4)
  Log.Message aqConvert.DateTimeToStr(Time5)
  Log.Message aqConvert.DateTimeToStr(Time6)
  Log.Message aqConvert.DateTimeToStr(Time7)
End Sub

DelphiScript

procedure ChangingTime;
var Time1, Time2, Time3, Time4, Time5, Time6, Time7;
begin
  Time1: = aqDateTime.Now;
  Time2: = aqDateTime.AddDays(Time1, 5);
  Time3: = aqDateTime.AddHours(Time1, 7);
  Time4: = aqDateTime.AddMinutes(Time1, 24);
  Time5: = aqDateTime.AddMonths(Time1, 2);
  Time6: = aqDateTime.AddSeconds(Time1, 15);
  Time7: = aqDateTime.AddTime(Time1, 9, 3, 24, 51);

  Log.Message(aqConvert.DateTimeToStr(Time1));
  Log.Message(aqConvert.DateTimeToStr(Time2));
  Log.Message(aqConvert.DateTimeToStr(Time3));
  Log.Message(aqConvert.DateTimeToStr(Time4));
  Log.Message(aqConvert.DateTimeToStr(Time5));
  Log.Message(aqConvert.DateTimeToStr(Time6));
  Log.Message(aqConvert.DateTimeToStr(Time7));
end;

C++Script, C#Script

function ChangingTime()
{
  var Time1, Time2, Time3, Time4, Time5, Time6, Time7;

  Time1 = aqDateTime["Now"]();
  Time2 = aqDateTime["AddDays"](Time1, 5);
  Time3 = aqDateTime["AddHours"](Time1, 7);
  Time4 = aqDateTime["AddMinutes"](Time1, 24);
  Time5 = aqDateTime["AddMonths"](Time1, 2);
  Time6 = aqDateTime["AddSeconds"](Time1, 15);
  Time7 = aqDateTime["AddTime"](Time1, 9, 3, 24, 51);

  Log["Message"](aqConvert["DateTimeToStr"](Time1));
  Log["Message"](aqConvert["DateTimeToStr"](Time2));
  Log["Message"](aqConvert["DateTimeToStr"](Time3));
  Log["Message"](aqConvert["DateTimeToStr"](Time4));
  Log["Message"](aqConvert["DateTimeToStr"](Time5));
  Log["Message"](aqConvert["DateTimeToStr"](Time6));
  Log["Message"](aqConvert["DateTimeToStr"](Time7));
}

See Also

Working With Dates
Working With Time
AddTime Method
AddMonths Method
AddDays Method
AddHours Method
AddMinutes Method
TimeInterval Method

Highlight search results