Skip to main content Skip to complementary content

inquartertodate - script and chart function

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


InQuarterToDate (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 inquartertodate function

Example diagram of the range of dates within which the inquartertodate function will return a value of TRUE. In this case, it returns TRUE for certain values in the first half of the second quarter of the year, and FALSE for all other values.

The inquartertodate() function divides the year into four equal quarters between January 1 and December 31 (or the user-defined start of year and its corresponding end date). Using the base_date, the function will then segment a particular quarter, with the base_date identifying both which quarter and the maximum allowed date for that quarter segment. Finally, the function returns a Boolean result when comparing the prescribed date values to that segment.

Argument Description
timestamp The date that you want to compare with base_date.
base_date Date that is used to evaluate the quarter.

The quarter can be offset by period_no. period_no is an integer, where the value 0 indicates the quarter which contains base_date. Negative values in period_no indicate preceding quarters and positive values indicate succeeding quarters.

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 inquartertodate() function returns a Boolean result. Typically, this type of function will be used as a condition in an if expression. The inquartertodate() function would be used to return an aggregation or calculation dependent on whether a date evaluated occurred in the quarter up to and including the date in question.

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

Function examples
Example Result
inquartertodate('01/25/2013', '03/25/2013', 0) Returns TRUE, since the value of timestamp, 01/25/2013, lies within the three-month period from 01/01/2013 to  03/25/2013, in which the value of base_date, 03/25/2013, lies.
inquartertodate('04/26/2013', '03/25/2013', 0) Returns FALSE, since 04/26/2013 is outside the same period as the previous example.
inquartertodate('02/25/2013', '06/09/2013', -1) Returns TRUE, since the value of period_no, -1, shifts the search period back one period of three months (one quarter of the year). This makes the search period 01/01/2013 to 03/09/2013.
inquartertodate('03/25/2006', '04/15/2006', 0, 2) Returns TRUE, since the value of first_month_of_year is set to 2, which makes the search period 02/01/2006 to 04/15/2006 instead of 04/01/2006 to 04/15/2006.

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.

Default regional settings in apps are based on the regional system settings of the computer or server where Qlik Sense is installed. If the Qlik Sense server you are accessing is set to Sweden, the Data load editor will use Swedish regional settings for dates, time, and currency. These regional format settings are not related to the language displayed in the Qlik Sense user interface. Qlik Sense will be displayed in the same language as the browser you are using.

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!