# Working with dates

This topic provides an example of how Qlik Application Automation for OEMcan keep track of dates and times.

## Convert dates to timestamps

You can use - formulas in placeholders to convert date formats. Here's an example automation, where we read and show the last update timestamp

from a record in a CRM:

In the second Output block, we convert the date to a unix timestamp (epoch timestamp, number of seconds since 1-1-1970):

In order to do this, we use the formula Date

with output format U

, which means a unix timestamp:

This is the raw view of the same formula, applied to the date:

Data to output: `Timestamp in epoch: {date: $.getContactByEmail2.updated_at, 'U'}`

## Compare two dates

Once dates are converted to a timestamp (which is just a number), you can use a Condition block to compare the two dates. Here's an example where we compare the timestamp last update from a contact with a timestamp equal to now minus 5 days

:

Note: the formula for the timestamp of now minus 5 days

can be added by clicking on the formula icon in the right top corner of the input field. Next, select the Date formula and enter now - 5 days

for the value, and U

for the output format (epoch timestamp).

## Calculate number of days between two dates

Next, we are using a variable called **days_difference** of type number

. In this variable, we will calculate the number of days between now and the above timestamp, in 3 steps.

First, we set the variable equal to the unix timestamp of now

:

Next, we subtract the previous timestamp:

As a third step, we divide by 86400 (the number of seconds in a day):

Finally, we round the result to get a whole number of days:

This is the raw view of the round

formula:

The overall output of this test automation would look as follows: