Skip to main content Skip to complementary content

makeweekdate - script and chart function

This function returns a date calculated from the year, the week number, and the day of week .

Syntax:  

MakeWeekDate(weekyear [, week [, weekday [, first_week_day [, broken_weeks [, reference_day]]]]])

Return data type: dual

The makeweekdate() function is available both as script and chart function. The function will calculate the date based on the parameters passed into the function.

Arguments
Argument Description
weekyear

The year as defined by the WeekYear() function for the specific date, that is the year to which the week number belongs.

Information noteThe week year can in some cases be different from the calendar year, for example if week 1 starts already in December of the previous year.
week

The week number as defined by the Week() function for the specific date.

If no week number is stated, 1 is assumed.

weekday

The day-of-week as defined by the WeekDay() function for the date in question. 0 is the first day of the week, and 6 is the last day of the week.

If no day-of-week is stated, 0 is assumed.

Information noteEven though 0 always means first day of the week and 6 is always the last, which weekdays that corresponds to is determined by the first_week_day parameter. If omitted, the value of variable FirstWeekDay is used.

If broken weeks are used, together with an impossible combination of parameters, this may lead to a result that does not belong to the chosen year.

Example:  

MakeWeekDate(2021,1,0,6,1)

Returns ‘Dec 27 2020’ since this day is the first day (the Sunday) of the specified week. Jan 1 2021 was a Friday.

first_week_day

Specifies the day on which the week starts. If omitted, the value of variable FirstWeekDay is used.

The possible values first_week_day are 0 for Monday, 1 for Tuesday, 2 for Wednesday, 3 for Thursday, 4 for Friday, 5 for Saturday, and 6 for Sunday.

For more information about the system variable, see FirstWeekDay.

broken_weeks

If you don't specify broken_weeks, the value of variable BrokenWeeks is used to define whether weeks are broken or not.

For more information about the system variable, see BrokenWeeks

reference_day

If you don't specify reference_day, the value of variable ReferenceDay is used to define which day in January to set as reference day to define week 1.

For more information about the system variable, see ReferenceDay

When to use it

The makeweekdate() function would commonly be used in the script for data generation to generate a list of dates, or to construct dates when the year, week and day-of-week are provided in the input data.

The following examples assume:

SET FirstWeekDay=0; SET BrokenWeeks=0; SET ReferenceDay=4;
Function examples
Example Result
makeweekdate(2014,6,6) returns 02/09/2014
makeweekdate(2014,6,1) returns 02/04/2014
makeweekdate(2014,6) returns 02/03/2014 (weekday 0 is assumed)

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 – day included

Example 2 – day excluded

Example 3 – Chart object 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!