This environment variable defines the date format used as the default in the app and by date returning functions like date() and date#(). The format is used to interpret and format dates. If the variable is not defined, the date format set by your regional settings is fetched when the script runs.
Syntax:
DateFormat
DateFormat Function examples
Example
Result
Set DateFormat='M/D/YY'; //(US format)
This use of the DateFormat function defines the date as the US format, month/day/year.
Set DateFormat='DD/MM/YY'; //(UK date format)
This use of the DateFormat function defines the date as the UK format, day/month/year.
Set DateFormat='YYYY/MM/DD'; //(ISO date format)
This use of the DateFormat function defines the date as the ISO format, year/month/day.
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.
The DateFormat function, which will use the US date format.
In this example, a dataset is loaded into a table named 'Transactions'. It includes a datefield. The US DateFormat definition is used. This pattern will be used for implicit text to date conversion when the text dates are loaded.
Load script
Set DateFormat='MM/DD/YYYY';
Transactions:
LOAD
date,
month(date) as month,
id,
amount
INLINE
[
date,id,amount
01/01/2022,1,1000
02/01/2022,2,2123
03/01/2022,3,4124
04/01/2022,4,2431
];
Results
Load the data and open a sheet. Create a new table and add these fields as dimensions:
The DateFormat definition MM/DD/YYYY is used for implicit conversion of text to dates, which is why the date field is properly interpreted as a date. The same format is used to display the date, as shown in the results table.
Example 2 – Change system variable
Overview
Open the Data load editor and add the load script below to a new tab.
The load script contains:
The same dataset from the previous example.
The DateFormat function, which will use the ‘DD/MM/YYYY’ format.
Load script
SET DateFormat='DD/MM/YYYY';
Transactions:
LOAD
date,
month(date) as month,
id,
amount
INLINE
[
date,id,amount
01/01/2022,1,1000
02/01/2022,2,2123
03/01/2022,3,4124
04/01/2022,4,2431
];
Results
Load the data and open a sheet. Create a new table and add these fields as dimensions:
date
month
Create this measure:
=sum(amount)
Results table
date
month
=sum(amount)
01/01/2022
Jan
1000
02/01/2022
Jan
2123
03/01/2022
Jan
4124
04/01/2022
Jan
2431
Because the DateFormat definition was set to ‘DD/MM/YYYY’, you can see that the two digits after the first “/” symbol have been interpreted as the month, resulting in all records being from the month of January.
Example 3 – Date interpretation
Overview
Open the Data load editor and add the load script below to a new tab.
The load script contains:
A dataset with dates in numerical format.
The DateFormat variable, which will use the ‘DD/MM/YYYY’ format.
The date() variable.
Load script
SET DateFormat='MM/DD/YYYY';
Transactions:
Load
date(numerical_date),
month(date(numerical_date)) as month,
id,
amount
Inline
[
numerical_date,id,amount
43254,1,1000
43255,2,2123
43256,3,4124
43258,4,2431
];
Results
Load the data and open a sheet. Create a new table and add these fields as dimensions:
date
month
Create this measure:
=sum(amount)
Results table
date
month
=sum(amount)
06/03/2022
Jun
1000
06/04/2022
Jun
2123
06/05/2022
Jun
4124
06/07/2022
Jun
2431
In the load script, you use the date() function to convert the numerical date into a date format. Because you do not provide a specified format as a second argument in the function, the DateFormat is used. This results in the date field using the format ‘MM/DD/YYYY’.
Example 4 – Foreign date formatting
Overview
Open the Data load editor and add the load script below to a new tab.
The load script contains:
A dataset of dates.
The DateFormat variable, which uses the ‘DD/MM/YYYY' format but is uncommented by forward slashes.
Load script
// SET DateFormat='DD/MM/YYYY';
Transactions:
Load
date,
month(date) as month,
id,
amount
Inline
[
date,id,amount
22-05-2022,1,1000
23-05-2022,2,2123
24-05-2022,3,4124
25-05-2022,4,2431
];
Results
Load the data and open a sheet. Create a new table and add these fields as dimensions:
date
month
Create this measure:
=sum(amount)
Results table
date
month
=sum(amount)
22-05-2022
-
1000
23-05-2022
-
2123
24-05-2022
-
4124
25-05-2022
-
2431
In the initial load script, the DateFormat being used is the default ‘MM/DD/YYYY’. Because the date field in the transactions dataset is not in this format, the field is not interpreted as a date. This is shown in the results table where the month field values are null.
You can verify the interpreted data types in the Data model viewer by inspecting the date field’s “Tags” properties.
This can be solved by enabling the DateFormat system variable:
// SET DateFormat='DD/MM/YYYY';
Remove the double forward slashes and reload the data.
Variable
A variable in Qlik Sense is a container storing a static value or a calculation, for example a numeric or alphanumeric value.
A Qlik Sense or QlikView app: Apps are task-specific, purpose-built applications. Apps contain data loaded from data sources that is interpreted through visualizations.
The Qlik Sense Mobile app: A mobile app for iOS and Android devices. In the mobile app, you connect to and interact with your cloud data. You can work with your available apps.
The term dataset is sometimes synonymous with table. It can refer to the original source table, the table after undergoing transformations, or the fact and dimension tables in a data mart.
It can also refer to a logical table, where there are several instance tables and views:
Current data
History, which holds previous versions of the table
A field contains values, loaded from a data source. At a basic level, a field corresponds to a column in a table. Fields are used to create dimensions and measures in visualizations.
A measure is a calculation base on one ore more aggregations. For example, the sum of sales is a single aggregation, while the sum of sales divided by the count of customers is a measure based on two aggregations.
The load script is a sequence of statements that defines what data to load and how to link the different loaded tables. It can be generated with the Data manager, or with the Data load editor, where it also can be viewed and edited.