Choose where you’d like to start

addWeek()

Overview

The addWeek() function takes dateTimeValue and numberOfWeeks as arguments. It returns the dateTimeValue after adding the specified number of weeks to it.

The date-time value will be returned in the format specified in Application Settings.

Return Type

  • Number

Syntax

<variable>=<dateTimeValue>.addWeek(<numberOfWeeks>);

(OR)

<variable>=addWeek(<dateTimeValue>, <numberOfWeeks>);
ParameterDescriptionData type
<variable>Variable which will contain the returned date-time value.NUMBER
<dateTimeValue>

The date-time value to which the specified number of weeks will be added.

The date-time value can be specified without a time value, in which case 00:00:00 will be taken as the default time value.

If the hour value is specified as 24 or more, the date-time value be reset to 00:00:00. If the minutes value is specified as 60 or more, the mm:ss value will be reset to 00:00, if the seconds value is specified as 60 or more, the ss value will be reset to 00.

A runtime error will be encountered if:

  • the hour value, or minute value, or second value, is specified in more than 2 digits.
  • the date value exceeds the number of days in that month.
  • the date value is specified in more than 2 digits.
  • the year value has more than 4 digits.

Refer this help document to learn about the supported date-time formats.

DATE-TIME
<numberOfWeeks>

The number of weeks to be added to dateTimeValue.

A negative number will subtract the specified number of weeks from dateTimeValue.

NUMBER

Examples

currentDate = '01-Jan-2019';
currentDateTime = '01-Jan-2019 15:00:00';
newDate = currentDate.addWeek(10);                        // returns '12-Mar-2019 00:00:00'
newDateTime = currentDateTime.addWeek(55);       // returns '21-Jan-2020 15:00:00'

Get Started Now

Execute