Skip to main content Skip to complementary content

Working with dates

This section shows how you work with dates in your automation using the convert date function.

For the complete list of date functions and formatting, see date functions.

Convert a date to a timestamp

Working with integers is easier than working with dates because they have a defined data type and Unix timestamps have a defined format. Unix timestamps represent a data as the number of seconds since 1-1-1970. You can convert dates to Unix timestamps by applying a data function formula. For example, this automation shows how to convert a Qlik Sense app creation date to a Unix timestamp.

Raw formula view of date function

Automation timestamp showing a simple automation and the raw output with a data conversion formula

The Get App Information block returns information about a Qlik Sense app. The output block outputs the createdDate key from the field mapped output of the preceding block. A formula is applied to the field mapping to covert the date to a time stamp. The 'U' parameter in the formula specifies that the date value should be converted to a Unix timestamp.

The raw formula to convert the date looks like this:


Compare two dates

Using the example from the previous section, we can easily compare dates once they are converted to a Unix timestamp. For example, this automation uses a condition block to determine if the app was created recently or whether it was created more than five days ago.

Raw formula view to compare dates

Automation compare dates showing both condition dates as Unix timestamps

The condition block converts the createdDate to a Unix timestamp and adds the condition greater than 5 days ago, as a Unix timestamp. Since the condition dates are both timestamps, they can easily be compared.

The raw formula to convert the second condition date looks like this:

{date:'now - 5 days','U'}

Calculate the difference between dates

Using the example from the first section, we can calculate the difference between two dates using a variable for the Unix timestamp. For example, this automation uses a variable to calculate the difference between the current date and the created date of the Qlik Sense app.

Inputs for variable block

Simple automation showing a variable that calculates the difference of dates

The variable block is set to the current date using a date formula to get the timestamp from now. This formula looks like this:


The variable has two more operations: one to substract the createdDate, which is the same formula as in the previous examples, and another to divide the result by the number of second in a day, which is 86400. This must be done because Unix timestamps are expressed in seconds. Configure the output block to show the difference in days.

Raw formula for output block

The output block configuration showing the string and variable that is output

To access the list of parameters when you are working on your automations, click on Show more in the Edit Formula dialog.

Edit formula input

Edit formula dialog box emphasizing the link to show the parameters that can be used when working with date functions

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!