This function returns an integer representing the hour when the fraction of the
expression is interpreted as a time
according to the standard number interpretation.
Syntax:
hour(expression)
Return data type: integer
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.
Function examples
Example
Result
hour(
'09:14:36' )
The text string supplied is implicitly converted to a timestamp as it matches the timestamp format defined in the TimestampFormat variable. The expression returns 9.
hour(
'0.5555' )
The expression returns 13 ( Because 0.5555 = 13:19:55 ).
Example 1 – Variable (script)
Overview
Open the Data load editor and add the load script below to a new tab.
The load script contains:
A dataset containing transactions by timestamp
The default TimeStamp system variable (M/D/YYYY h:mm:ss[.fff] TT)
Create a field 'hour', calculating when purchases took place.