aqDateTime.AddTime Method

Applies to TestComplete 15.45, last modified on December 01, 2022

Description

The aqDateTime.AddTime method adds or subtracts the specified number of days, hours, minutes and seconds to (from) the specified Date/Time value.

Declaration

aqDateTime.AddTime(InputDate, Days, Hours, Minutes, Seconds)

InputDate [in]    Required    Date/Time    
Days [in]    Required    Integer    
Hours [in]    Required    Integer    
Minutes [in]    Required    Integer    
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.

Days

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

Hours

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

Minutes

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

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 DateTime value that is the result of addition or subtraction.

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
AddMonths Method
AddDays Method
AddHours Method
AddMinutes Method
AddSeconds Method
TimeInterval Method

Highlight search results