Manipulating dates in automations

How to manipulate and use relative dates inside automations

Dates in automations

Some automations may use date and datetime fields as their outputs. Normally, if you're only feeding these outputs directly into Jestor itself (for example, marking a Finish Date as a kanban card enter the last stage), you don't have to worry about it! You can just set up the automation as usual and they'll work as expected.

However, sometimes you may need to manipulate dates in some manner. For example, you may want to create a task with a deadline of three days from creation. Similarly, you may want to send a notification with a datetime value in a specific formatting (for example, m/d/Y).

For those cases, there are some inbuilt ways of manipulating dates in no-code automations.

Getting "Now" and its relative dates

One of the most useful date values is the moment when the automation runs. To use this information in an automation, all you have to do is write the following:

{{date()}}

If you wish to get a relative date to "now", you can pass it as a parameter inside this date() function. For example, if you wish to get 'yesterday' (from the moment the automation runs), all you have to do is write:

{{date('yesterday')}}

You can also pass formatting and manipulation parameters inside this function, so the snippet below would serve to get today's date, add 5 days, and present it in the m/d/Y format:

{{date('today','m/d/Y','+5 days')}}

Formatting and modifying other dates

You can also manipulate values from date fields using date_format() and date_modify(). Those can be useful for processes when the automation run date is irrelevant, and you have other specific values you have to use. These functions can be used by appending a vertical bar "|" and the function after a field's name.

The date_format() function allows you to change a date's format. In the example below, we're formatting the value inside the start_date field to the Y-m-d format.

{{start_date|date_format('Y-m-d')}}

The date_modify() function allows you to manipulate a date's value. In the example below, we're adding 5 days to the start_date field.

{{start_date|date_modify('+5 days')}}

Do note that date_modify() also includes the date_format as a second parameter, so you can do both at the same time:

{{start_date|date_modify('+5 days','Y-m-d')}}