Skip to main content

PQL47 (PQL Function Library - CPM 4.7)

ADD_MONTHS

Applies to: CELONIS 4.0 CELONIS 4.2 CELONIS 4.3 CELONIS 4.4 CELONIS 4.5 CELONIS 4.6 CELONIS 4.7

Description

ADD_MONTHS adds a given number of months to a given date.

Supported input column types: base_column -> DATE, months_column -> INT

Output column type: DATE

If the input date is last day of the month, the resulting date will be last day of the month.

Syntax
ADD_MONTHS ( table.base_column, table.months_column )
NULL handling

If any parameter is NULL, the result is NULL as well.

Date range: If a result of type DATE is outside the interval from the year 1400 CE (including) to the year 10000 CE (excluding), it will normally be mapped to NULL. This is not the case for this function:

  • Results outside the interval will still be DATE values.

  • However there are no longer any guarantees with regard to the correctness of the resulting values outside the interval.

Example

[1] Simple example for ADD_MONTHS.

Query

Column1

ADD_MONTHS ( "Table1"."Base_Column" , "Table1"."Month_Column" )

Input

Output

Table1

Base_Column : DATE

Month_Column : INT

Mon Jan 01 2018 00:00:00.000

12

Mon Jan 01 2018 00:00:00.000

1

Mon Jan 01 2018 00:00:00.000

0

Mon Jan 01 2018 00:00:00.000

-1

Result

Column1 : DATE

Tue Jan 01 2019 00:00:00.000

Thu Feb 01 2018 00:00:00.000

Mon Jan 01 2018 00:00:00.000

Fri Dec 01 2017 00:00:00.000

[2] Simple example for ADD_MONTHS.

Query

Column1

ADD_MONTHS ( "Table1"."Column1" , "Table1"."Integer" )

Input

Output

Table1

Column1 : DATE

Integer : INT

Fri Jan 31 2020 00:00:00.000

1

Tue Dec 31 2019 00:00:00.000

2

Mon Dec 31 2018 00:00:00.000

14

Wed Feb 28 2018 00:00:00.000

24

Sat Feb 29 2020 00:00:00.000

14

Result

Column1 : DATE

Sat Feb 29 2020 00:00:00.000

Sat Feb 29 2020 00:00:00.000

Sat Feb 29 2020 00:00:00.000

Sat Feb 29 2020 00:00:00.000

Fri Apr 30 2021 00:00:00.000

[3] ADD_MONTHS behaviour when input date is last day of the month. The resulting date is also end of the month.

Query

Column1

ADD_MONTHS ( "Table1"."Column1" , "Table1"."Integer" )

Input

Output

Table1

Column1 : DATE

Integer : INT

Fri Jan 31 2020 00:00:00.000

3

Mon Nov 30 2020 00:00:00.000

2

Result

Column1 : DATE

Thu Apr 30 2020 00:00:00.000

Thu Apr 30 2020 00:00:00.000