This function returns the current Greenwich
Mean Time, as derived from the regional settings. The function returns values in the TimestampFormat system variable format.
Whenever the app is reloaded, any load script table, variable or chart object that uses the GMT function will be adjusted to the latest current Greenwich Mean Time as derived from the system clock.
Syntax:
GMT( )
Return data type: dual
These examples use the timestamp format M/D/YYYY h:mm:ss[.fff] TT. The date format is specified in the SET TimestampFormat statement at the top of your data load script. Change the format in the examples to suit your requirements.
Function examples
Example
Result
GMT()
3/28/2022 2:47:36 PM
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 - Variable (script)
Overview
Open the Data load editor and add the load script below to a new tab. This example will set the current Greenwich Mean Time as a variable in the load script using the GMT function.
Load script
LET vGMT = GMT();
Results
Load the data and create a sheet. Create a text box using the Text & image chart object.
Add this measure to the text box:
=vGMT
The text box should contain a line of text with a date and time, similar to the one shown below:
3/28/2022 2:47:36 PM
Example 2 - November start of year (script)
Overview
Open the Data load editor and add the load script below to a new tab.
The load script contains:
A dataset containing overdue library books, which is loaded into a table named Overdue. The default DateFormat system variable MM/DD/YYYY is used.
The creation of a new field called days_overdue, which calculates how many day overdue each book is.
Load the data and open a sheet. Create a new table and add these fields as dimensions:
due_date
book_id
days_overdue
Results table
due_date
book_id
days_overdue
01/01/2021
4
455
01/10/2021
24
446
01/31/2021
173
425
02/01/2021
281
424
02/10/2021
265
415
06/30/2021
465
275
07/26/2021
537
249
10/31/2021
275
152
11/01/2021
455
151
12/31/2021
46
91
The values in the days_overdue field are calculated by finding the difference between the current Greenwich Mean Time, using the GMT() function, and the original due date. In order to calculate only the days, the results are rounded off to the nearest whole number using the Floor() function.
Example 3 - chart object (chart)
Overview
Open the Data load editor, and add the load script below to a new tab. The load script contains the same dataset as the previous example. The default DateFormat system variable MM/DD/YYYY is used.
However, in this example, the unchanged dataset is loaded into the application. The value of the number of days overdue is calculated via a measure in a chart object.
Load the data and open a sheet. Create a new table and add these fields as dimensions:
due_date
book_id
Create the following measure:
=Floor(GMT() – due_date)
Results table
due_date
book_id
=Floor(GMT()-due_date)
01/01/2021
4
455
01/10/2021
24
446
01/31/2021
173
425
02/01/2021
281
424
02/10/2021
265
415
06/30/2021
465
275
07/26/2021
537
249
10/31/2021
275
152
11/01/2021
455
151
12/31/2021
46
91
The values in the days_overdue field are calculated by finding the difference between the current Greenwich Mean Time, using the GMT() function, and the original due date. In order to calculate only the days, the results are rounded off to the nearest whole number using the Floor() function.
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!