Skip to main content

weekday - script and chart function

This function returns a dual value with:

  • A day name as defined in the environment variable DayNames.
  • An integer between 0-6 corresponding to the nominal day of the week (0-6).


weekday(date [,first_week_day=0])

Return data type: dual

The weekday() function determines which day of the week a date occurs on. It then returns a string value representing that day.

Diagram of weekday() function that returns the name of the day a date falls on

Diagram that shows the weekday() function returns the name of the day that a date falls on.

The result returns the number value corresponding to that day of the week (0-6), based on the week’s start day. For example, if the first day of the week is set to Sunday, a Wednesday will return a number value of 3. This start day is determined either by the FirstWeekDay system variable, or the first_week_day function parameter.

You can use this number value as a part of an arithmetic expression. For example, multiply it by 1 to return the value itself.

Diagram of weekday() function with the number value of the day being shown instead of the name of the day

Diagram that shows the weekday() function can return a number value that corresponds to the day which is identified.

The weekday() function is useful when you want to compare aggregations by day of the week. For example, if you want to compare the average sales of products by weekday.

These dimensions can be created in the load script by using the function to create a field in a Master Calendar table; or created directly in a chart as a calculated measure.

Related topics
Topics Interaction
FirstWeekDay Defines the start day of each week.
Argument Description
date The date to evaluate.

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


You can use the following values to set the day on which the week starts in the first_week_day argument:

first_week_day values
Day Value
Monday 0
Tuesday 1
Wednesday 2
Thursday 3
Friday 4
Saturday 5
Sunday 6

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.

Information noteUnless stated otherwise, FirstWeekDay is set to 0 in these examples.
Function examples
Example Result
weekday('10/12/1971') Returns 'Tue' and 1.
weekday('10/12/1971' , 6)

Returns 'Tue' and 2.

In this example, Sunday (6) is the first day of the week.

SET FirstWeekDay=6;



Returns 'Tue' and 2.

Example 1 - Weekday string

Example 2 - first_week_day

Example 3 - Chart object example

Example 4 - Scenario