addMonth function

The addMonth function adds a given number of months to a date attribute.


Parameters

addMonth(date, nmonth)

Parameter

Description

date

The date attribute we want to add months to. The date parameter is mandatory.

nmonth

The number of months to add to the chosen date attribute. The nmonth parameter is mandatory.

Date type valid formats (if the values aren’t this format, the function will return an error).

  • 2019/10/12;

  • 12/10/2019;

  • 2019-10-12;

  • 12-10-2019;

  • 2019/Oct/12;

  • 12/Oct/2019;

  • 2019-Oct-12;

  • 12-Oct-2019.


Example

The following example uses the Bike sales dataset.

Description

Screenshot

In this example, we want to add 2 months to the reported date, which is the attribute Date.

We type the following formula in the addmonth attribute:

addMonth($"Date",2)

and the attribute will be filled with the Date attribute’s values postponed by two months.

The results are:

  • In row 1 the value 2013-11-26 becomes 2014-01-26,

  • In row 2 the value 2015-11-26 becomes 2016-01-26,
    and so on