Qlik Sense Integer Functions of Time With Syntax

FREE Online Courses: Click, Learn, Succeed, Start Now!

1. Objective

In our last Qlik Sense Tutorial, we discussed Qlik Sense Time Zone Functions. Today we will see Qlik Sense Integer Functions of Time. The integer functions of time are used to evaluate time and return the resultant value as integers. Moreover, we will discuss Qlik Sense Integer Functions of Time with the help of example and syntax.

So, let’s start Qlik Sense Integer Functions tutorial.

Qlik Sense Integer Functions

Qlik Sense Integer Functions of Time With Syntax

Have a look at Qlik Sense Logical Functions

2. Qlik Sense Integer Functions

Following are some Qlik Sense Integer Functions, let’s discuss them in detail –

i. second() function

The second() function returns seconds from the timestamp as an integer value. The timestamp is an expression which punches the current time and present date in the system’s memory.

The syntax of Qlik Sense second function:


Where expression is the time in standard number interpretation.

For example,

The expression, second(’09:30:36′) will return 36 as it is the value of seconds on the given time.

Also, if you give time in a function as, second(‘5: 14: 0.5555’) then the function will return 55 ( Because 0.5555 = 5:14:55 as per the standard time interpretation).

ii. minute() function

This function returns the minute part of time recorded at an instant. The time recorded is referred to as timestamp which shows the time in standard number interpretation. The minutes returned by this function is as an integer value.

Let’s discuss Qlik Sense mathematical Functions

The syntax of Qlik Sense minute function:


For example,

The expression minute(’11:14:36′) will return 14 as the minute in the time.

And if you only mention one part of the timestamp, even then the minutes will be returned by the function, minute(‘0.5555’) returns 19 , because 0.5555 = 13:19:55  which is the time stamp.

iii. hour() function

The hour() function returns the hour part of the time, present in standard number interpretation. The value returned by this function is as an integer value.

The syntax of Qlik Sense hour function:


For example,

In the time given in the example, hour(’10:15:36′) the hour will be returned as 10.

Also, if you only mention one element of the time in the timestamp like, hour(’15’) returns 10, because 15 is a minute element in the date 10:19:55.

iv. day() function

The day() function returns an integer value for the day mentioned in the date recorded in the timestamp or a date entered manually.

Know more about Qlik Sense mapping Functions

The Syntax of Qlik Sense day function:


For example, if the day function has a date, day(22/02/1998) then the function will return 22 the integer value for day. Also, if you enter the number of days a particular date or day will on, this function will return the day of that date.

For example, day(‘35648’) will return 6, because 35648 is the total days for the date 6/08/1997.

v. week() function

This function returns the nth week or the number of week when it encounters a date.

The syntax of Qlik Sense week function:


Where, timestamp is the date, first_week_day is the number that you specify the day you want your week to start. Like, 0 for Monday, 1 for Tuesday, 2 for Wednesday, 3 for Thursday, 4 for Friday, 5 for Saturday and 6 for Sunday.

broken_weeks sets the starting of counting the weeks from January of a year. There are two ways to set this, first is to use 0 for unbroken weeks i.e. week 1 will start on January 1, which is not usually a full week. The other option is to use 1 for broken weeks were the first week of January must at least have 4 days and so, it doesn’t necessarily start from 1st of January. By default, Qlik Sense used unbroken weeks.

reference_day decides the which day in the first week of January should be taken as the start of the 1st week. You can use, 1 (= January 1), 2 (= January 2), 3 (= January 3), 4 (= January 4), 5 (= January 5), 6 (= January 6), 7 (= January 7) and so on. By default, this is set on 4.

For example,

In the expression week(‘2012-10-12’) the result would be 41. And if you use week(‘2012-10-12’, 0, 1) as the expression, where 0 is the first week day and 1 to specify broken weeks, returns 42 as the week number.

Have a look at Qlik Sense Counter Functions

vi. month() function

The month() function returns the month of a date both in text and number. As it returns both text (Jan to Dec) and numeric values (1 to 12) of month, it is said to be dual data format.

The syntax of Qlik Sense month Function:


For example,

The expression, month(‘2017-10-12’) returns Oct as the text result to the function and the numeric value would be 10.

vii. year() function

The year() function returns the year by evaluating a date encountered in  a script in standard numeric interpretation.

The Syntax of Qlik Sense Year Function:


For example,

The expression with a date, year(‘2017-10-12’) will return 2017 as it is the year.

If the expression contains number of days instead of a date then,

year(‘35648’) where 35648 is the number of the day on which the date1997-08-06 will fall on, and so, it will evaluate the date from the number ‘35648’ and return 1997.

Let’s take a tour to Qlik Sense color function

viii. weekyear() function

This function returns the year corresponding to the number of week which is present in a date. The number of weeks in a year range from 1 to about 52 (may vary).

The syntax of Qlik Sense weekyear Function:


For example,

The date given in the expression, weekyear(‘1996-12-30’) will return 1997, because week 1 of 1998 starts on 1996-12-30 and so will it be for the year 1997.

Or, weekyear(‘1997-01-02’) will return 1997 as the year corresponding to the first week of 1997.

Or, weekyear(‘1997-12-30’) which returns 1998 as week 1 of 1998 starts on 1997-12-29.

ix. weekday() function

The weekday() function will return the weekday corresponding to a date. The value returned is dual i.e. it is both in text (Mon, Tue, Wed and so on till Sun) and number (from 0 to 6, where 0 is Monday and 6 is for Sunday).

The syntax of Qlik Sense weekday function:

weekday(date [,first_week_day=0])

Where from the first_week_day parameter, you can specify which day (0 for Monday to 6 for Sunday) you want to be as the first day of the week.

Do you know about Qlik Sense Pie chart

For example,

The expression, weekday(‘1971-10-12’) will return ‘Tue’ and 1 because Monday would be 0 and so Tuesday is assigned to 1.

And if you specify the number of day a week should start from in the place of first_week_day parameter,

weekday(‘1971-10-12’ , 6)

will return ‘Tue’ and 2 because here as it is been specified the week should start from Sunday(6) and so according to this, Sunday is 0, Monday is 1 and Tuesday is 2.

So, this was all in Qlik Sense integer functions of time. Hope you like our explanation.

3. Conclusion

Thus, the time integer functions are useful in giving important information related to time as integer values. They also return string or text values when required by some function, which makes using these functions very convenient.

Still, if you have any query regarding Qlik Sense Integer Functions, ask in the comment tab.

See also –  

Qlik Sense Histogram Visualization

Reference for Qlik Sense 

Your opinion matters
Please write your valuable feedback about DataFlair on Google

follow dataflair on YouTube

Leave a Reply

Your email address will not be published. Required fields are marked *