Skip to main content Skip to complementary content

lunarweekend - script and chart function

This function returns a value corresponding to a timestamp of the last millisecond of the last day of the lunar week containing date. Lunar weeks in Qlik Sense are defined by counting January 1 as the first day of the week and, apart from the final week of the year, will contain exactly seven days.

Syntax:  

LunarweekEnd(date[, period_no[, first_week_day]])

Return data type: dual

Example diagram of lunarweekend() function

ADD ALT TEXT HERE.....!!!!!!

The lunarweekend() function determines which lunar week the date falls into. It then returns a timestamp, in date format, for the last millisecond of that week.

Arguments
Argument Description
date The date or timestamp to evaluate.
period_no period_no is an integer or expression resolving to an integer, where the value 0 indicates the lunar week which contains date. Negative values in period_no indicate preceding lunar weeks and positive values indicate succeeding lunar weeks.
first_week_day An offset that may be greater than or less than zero. This changes the beginning of the year by the specified number of days and/or fractions of a day.

When to use it

The lunarweekend() function is commonly used as part of an expression when the user would like the calculation to use the fraction of the week that has not yet occurred. Unlike the weekend() function, the final lunar week of each calendar year will end on December 31. For example, the lunarweekend() function can be used to calculate interest not yet incurred during the week.

Function examples
Example Result
lunarweekend('01/12/2013') Returns 01/14/2013 23:59:59.
lunarweekend('01/12/2013', -1) Returns 01/07/2013 23:59:59.
lunarweekend('01/12/2013', 0, 1) Returns 01/15/2013 23:59:59.

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_week_day

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!