Skip to main content Skip to complementary content

daystart - script and chart function

This function returns a value corresponding to a timestamp with the first millisecond of the day contained in the time argument. The default output format will be the TimestampFormat set in the script.

Syntax:  

DayStart(time[, [period_no[, day_start]])

Return data type: dual

Arguments
Argument Description
time The timestamp to evaluate.
period_no period_no is an integer, or expression that resolves to an integer, where the value 0 indicates the day that contains time. Negative values in period_no indicate preceding days and positive values indicate succeeding days.
day_start To specify that days do not starting at midnight, indicate an offset as a fraction of a day in day_start. For example, 0.125 to denote 3:00 AM.

In other words, to create the offset, divide the start time by 24 hours. For example, for a day to begin at 7:00 AM, use the fraction 7/24.

When to use it

The daystart() function is commonly used as part of an expression when the user would like the calculation to use the fraction of the day that has elapsed thus far. For example, it could be used to calculate the total wages earned by employees in the day so far.

These examples use the timestamp format 'M/D/YYYY h:mm:ss[.fff] TT'. The timestamp format is specified in the SET TimeStamp statement at the top of your data load script. Change the format in the examples to suit your requirements.

Function examples
Example Result
daystart('01/25/2013 4:45:00 PM') Returns 1/25/2013 12:00:00 AM.
daystart('1/25/2013 4:45:00 PM', -1) Returns 1/24/2013 12:00:00 AM.
daystart('1/25/2013 16:45:00',0,0.5 ) Returns 1/25/2013 12:00:00 PM.

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.

Example 1 - Simple example

Example 2 - period_no

Example 3 - day_start

Example 4 - Chart object example

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!