Early Access: The content on this website is provided for informational purposes only in connection with pre-General Availability Qlik Products.
All content is subject to change and is provided without warranty.
Skip to main content Skip to complementary content

inyeartodate - script and chart function

This function returns True if timestamp lies inside the part of year containing base_date up until and including the last millisecond of base_date.

Syntax:  

InYearToDate (timestamp, base_date, period_no[, first_month_of_year])

Return data type: Boolean

Information note

In Qlik Sense, the Boolean true value is represented by -1, and the false value is represented by 0.

Diagram of inyeartodate function

Example diagram of the range of dates within which the inyeartodate function will return a value of TRUE.

The inyeartodate() function will segment a particular portion of the year with the base_date, identifying the maximum allowed date for that year segment. The function then evaluates whether a date field or value falls into this segment and returns a Boolean result.

Arguments
Argument Description
timestamp The date that you want to compare with base_date.
base_date Date that is used to evaluate the year.
period_no The year can be offset by period_no. period_no is an integer, where the value 0 indicates the year that contains base_date. Negative values in period_no indicate preceding years, and positive values indicate succeeding years.
first_month_of_year If you want to work with (fiscal) years not starting in January, indicate a value between 2 and 12 in first_month_of_year.

When to use it

The inyeartodate() function returns a Boolean result. Typically, this type of function will be used as a condition in an if expression. This would return an aggregation or calculation dependent on whether a date evaluated occurred in the year up to and including the date in question.

For example, the inyeartodate() function can be used to identify all equipment manufactured in a year up to a specific date.

These examples use the date format MM/DD/YYYY. The date format is specified in the SET DateFormat statement at the top of your data load script. Change the format in the examples to suit your requirements.

Function examples
Example Result
inyeartodate ('01/25/2013', '02/01/2013', 0) Returns TRUE.
inyeartodate ('01/25/2012', '01/01/2013', 0) Returns FALSE.
inyeartodate ('01/25/2012', '02/01/2013', -1) Returns TRUE.
inyeartodate ('11/25/2012', '01/31/2013', 0, 4) Returns TRUE.
The value of timestamp falls inside the fiscal year beginning in the fourth month and before the value of base_date.
inyeartodate ('3/31/2013', '01/31/2013', 0, 4 ) Returns FALSE.
Compared with the previous example, the value of timestamp is still inside the fiscal year, but it is after the value of base_date, so it falls outside the part of the year.

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 – No additional arguments

Example 2 – period_no

Example 3 – first_month_of_year

Example 4 – Chart object example

Example 5 – 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!