Skip to main content

monthstart - script and chart function

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


MonthStart(date[, period_no])

Return data type: dual

Diagram of monthstart() function

Example diagram of how the elements of the function work together to return the result. The monthstart takes an input date and converts it to a timestamp of the first millisecond of the month in which the date occurs.

The monthstart() function determines which month the date falls into. It then returns a timestamp, in date format, for the first millisecond of that month.

Argument Description
date The date 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.

When to use it

The monthstart() function is commonly used as part of an expression when the user would like the calculation to use the fraction of the month that has elapsed thus far. For example, it can be used to calculate the interest that has been accumulated in a month up to a certain date.

Function examples
Example Result
monthstart('10/19/2001') Returns 10/01/2001.
monthstart('10/19/2001', -1) Returns 09/01/2001.

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 app regional settings.

Default regional settings in apps are based on a combination of identity provider settings, system settings, or browser settings. 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.

Example 1 – No additional arguments

Example 2 – period_no

Example 3 – Chart object example

Example 4 – Scenario