Skip to main content Skip to complementary content

indaytotime - script and chart function

This function returns True if timestamp lies inside the part of day containing base_timestamp up until and including the exact millisecond of base_timestamp.

Syntax:  

InDayToTime (timestamp, base_timestamp, period_no[, day_start])

The indaytotime() function returns a Boolean result depending on when a timestamp value occurs during the segment of the day. The start boundary of this segment is the start of the day, which is set as midnight by default; the start of the day can be modified by the day_start argument of the indaytotime() function. The end boundary of the day segment is determined by a base_timestamp argument of the function.

Diagram of indaytotime function.

Diagram showing the relations between the variables of the indaytotime function.

The indaytotime() function returns a Boolean result. Typically, this type of function will be used as a condition in an if expression. The indaytotime() function returns an aggregation or calculation depending on if a timestamp occurred in the segment of the day up to and including the time of the base timestamp.

For example, the indaytotime() function can be used to show the sum of ticket sales for shows that have taken place so far today.

Return data type: Boolean

In Qlik Sense, the Boolean true value is represented by -1, and the false value is represented by 0.

Arguments
Argument Description
timestamp The date and time that you want to compare with base_timestamp.
base_timestamp Date and time that is used to evaluate the timestamp.
period_no The day can be offset by period_no. period_no is an integer, where the value 0 indicates the day which contains base_timestamp. Negative values in period_no indicate preceding days and positive values indicate succeeding days.
day_start (optional) If you want to work with days not starting midnight, indicate an offset as a fraction of a day in day_start. For example, use 0.125 to denote 3 AM.

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.

If you are an app creator, you can set the default region for apps you create. For more information, see Setting your preferred regional settings for creating apps and scripts in Qlik Cloud Analytics.

Function examples
Example Result
indaytotime ('01/12/2006 12:23:00 PM', '01/12/2006 11:59:00 PM', 0) Returns True
indaytotime ('01/12/2006 12:23:00 PM', '01/12/2006 12:00:00 AM', 0) Returns False
indaytotime '01/11/2006 12:23:00 PM', '01/12/2006 11:59:00 PM', -1) Returns True

Example 1 – no additional arguments

Example 2 – period_no

Example 3 – day_start

Example 4 – Chart object

Example 5 – Scenario

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!