Skip to main content Skip to complementary content

inday - script and chart function

This function returns True if timestamp lies inside the day containing base_timestamp.

Syntax:  

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

Diagram of inday function

Diagram that shows how the inday function is used to identify a segment of time and return boolean results based on that segment.

The inday() function uses the base_timestamp argument to identify which day the timestamp falls into. The start time of the day is, by default, midnight; but you can change the start time of the day by using the day_start argument of the inday() function. Once this day is defined, the function will return Boolean results when comparing the prescribed timestamp values to that day.

The inday() function returns a Boolean result. Typically, this type of function will be used as a condition in an if expression. This returns an aggregation or calculation dependent on whether a date evaluated occurred in the day of the timestamp in question.

For example, the inday() function can be used to identify all equipment manufactured in a given day.

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 If you want to work with days not starting midnight, indicate an offset as a fraction of a day in day_start, For example, 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
inday ('01/12/2006 12:23:00 PM', '01/12/2006 12:00:00 AM', 0) Returns True
inday ('01/12/2006 12:23:00 PM', '01/13/2006 12:00:00 AM', 0) Returns False
inday ('01/12/2006 12:23:00 PM', '01/12/2006 12:00:00 AM', -1) Returns False
inday ('01/11/2006 12:23:00 PM', '01/12/2006 12:00:00 AM', -1) Returns True
inday ('01/12/2006 12:23:00 PM', '01/12/2006 12:00:00 AM', 0, 0.5) Returns False
inday ('01/12/2006 11:23:00 AM', '01/12/2006 12:00:00 AM', 0, 0.5) Returns True

Example 1 – Load statement (script)

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!