Skip to main content Skip to complementary content

monthend - script and chart function

This function returns a value corresponding to a timestamp of the last millisecond of the last day of the month containing date. The default output format will be the DateFormat set in the script.


MonthEnd(date[, period_no])

In other words, the monthend() function determines which month the date falls into. It then returns a timestamp, in date format, for the last millisecond of that month.

Diagram of monthend function.

Diagram showing how monthend function can be used to identify the latest timestamp of a chosen month.

The monthend() function is used as part of an expression when you would like the calculation to use the fraction of the month that has not yet occurred. For example, if you want to calculate the total interest not yet incurred during the month.

Return data type: dual

Argument Description
date The date or timestamp to evaluate.
period_no period_no is an integer, which, if 0 or omitted, indicates the month that contains date. Negative values in period_no indicate preceding months and positive values indicate succeeding months.

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.

Function examples
Example Result
monthend('02/19/2012') Returns 02/29/2012 23:59:59.
monthend('02/19/2001', -1) Returns 01/31/2001 23:59:59.

Example 1 – Basic example

Example 2 – period_no

Example 3 – Chart example

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