Skip to main content Skip to complementary content

addyears - script and chart function

This function returns the date occurring n years after startdate or, if n is negative, the date occurring n years before startdate.

Syntax:  

AddYears(startdate, n)

Return data type: dual

Example diagram of addyears() function

Example diagram showing how the various components of the addyears function come together to produce an output date.

The addyears() function adds or subtracts a defined number of years, n, from a startdate. It then returns the resulting date.

Arguments
Argument Description
startdate

The start date as a time stamp, for example '2012-10-12'.

n Number of years as a positive or negative integer.
Function examples
Example Result
addyears ('01/29/2010',3) Returns '01/29/2013'.
addyears ('01/29/2010',-1) Returns '01/29/2009'.

Regional settings

Unless otherwise specified, the examples in this topic use the following date format: MM/DD/YYYY. The date format is specified in the SET DateFormat statement in your data load script. The default date formatting may be different in your system, due to your regional settings and other factors. You can change the formats in the examples below to suit your requirements. Or you can change the formats in your load script to match these examples. For more information, see Modifying regional settings for apps and scripts.

Default regional settings in apps are based on the user profile. These regional format settings are not related to the language displayed in the Qlik Cloud user interface. Qlik Cloud will be displayed in the same language as the browser you are using.

If you are an app creator, you can set the default region for apps you create. For more information, see Setting your preferred regional settings for creating apps and scripts in Qlik Cloud Analytics.

Example 1 – Simple example

Example 2 – Chart object example

Example 3 – Scenario

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!