Qlik Sense Time Zone Function With Example
In our last Qlik Sense Tutorial, we discussed Qlik Sense In function. Today, we will see the Qlik Sense Time Zone Function. The functions explained below serves specifically in dealing with time zones of different countries. You can use these functions easily as a chart or script function.
So, let’s start Qlik Sense Time Zone Function Tutorial.
2. Qlik Sense Time Zone Function
Following are the Qlik Sense Time Zone Function, let’s discuss them in detail –
i. timezone() function
We use the Qlik Sense timezone() function to return the current time zone using the information provided by the system. Usually, in your system’s details the time zone it operated on is stored. This function responds by returning a string data type.
The syntax of Qlik Sense timezone function:
For example, if you operate on a windows based system, in India, then upon using the TimeZone() function, you will get IST as the answer or result after script execution.
ii. GMT() function
This function returns the current GMT which is Greenwich Mean Time, using the system’s clock and windows time settings. The response is in dual data format that is both strings and integers are returned.
The syntax of GMT Function in Qlik Sense:
For example, if the current time according to GMT is 6:00, then using this function gmt() in the Qlik Sense script will return GMT-6:00.
iii. UTC() function
The UTC function returns the Coordinated Universal Time, abbreviated as UTC. It returns a dual data type value, which has both the string and numeric interpretations of date and time according to UTC.
The syntax of Qlik sense UTC Function:
For example, if you right now enter the utc() function in the script, it will return the current UTC time and date.
2018/10/26, 20:17:12-UTC as the current UTC time.
iv. daylightsaving() function
The daylight savings time is adjusting the clock a few hours forward or backward, depending upon how warm or cold the weather is because the duration of daylight varies depending on the weather. This function is used to return the current adjustments done in your system’s clock for the daylight-saving phenomenon. However, it is not necessary and always that a country or region is experiencing such shifts. This function returns the value in dual data format.
The syntax of daylightsaving function in Qlik Sense:
v. converttolocaltime() function
This function is used when you want to convert a UTC or GMT to a local time zone of any region, place or country. This function returns a dual value that is both string and text representation. There are many countries which are considered as valid places and time zones to use this function on.
The syntax of Qlik Sense Converttolocaltime function:
ConvertToLocalTime(timestamp [,place [,ignore_dst=false]])
Where timestamp is the current recorded time (UTC or GMT) which will be converted into a local time zone.
The place parameter specifies the place or even takes UTC or GMT values to evaluate the time and date accordingly. You can refer to any list online of valid places and time zones.
The ignore_dst=false can be set to True if you want to ignore the Daylight savings time adjustment in your system. And if not, then set the ignore_dst parameter to False.
The expression, ConvertToLocalTime(‘2007-11-10 23:59:00′,’Paris’) will return ’2007-11-11 00:59:00’ as it is for Paris at the given time. This will be stored as a timestamp in the memory.
The local time for the North American east coast place like New York, without daylight-saving time adjustment.
In the sample expression given above, UTC() is the current time in UTC which we want to convert into a local time zone. Where GMT-05:00 tells the time of the current time zone in GMT mode and the ignore_dst has been set to True which ignores the daylight savings time adjustments done by the system.
So, this was all in Qlik Sense Time Zone Function. Hope you like our explanation.
Hence, these were all the functions we use in handling timezone related issues. We can simply use functions like GMT, UTC, timezone, to see what time it is according to a specific time zone. Or, we can use daylightsaving and converttolocal functions which performs more complex calculations and returns corresponding values. Such functions are very convenient, easy to understand and apply in time zone related operations of the enterprise as in most cases the business spread at places around the globe.
See also –