Calculating with dates 2.0

How can i make a difference between two dates that’s being inputted.
{%=$1+input custom.dieselpw.begindatum as:date %}
{%=$2+input custom.dieselpw.einddatum as:date %}

i want to have the amount of days between $1 and $2 but i only get the difference between the days of input 1 and input 2

Hi Matthijs

Do you mean something like this?

{{ $2-$1-1 | integer }}

Kind regards
Sam

yes, but here is the result
image
he doesn’t calculate with the months…

Right, forgot about that for a second.
You can solve it by doing this.

{%=$1+input custom.dieselpw.begindatum as:date %}
{%=$2+input custom.dieselpw.einddatum as:date %}

{% assign beginDate = custom.dieselpw.begindatum | date: ‘%s’ %}
{% assign endDate = custom.dieselpw.einddatum | date: ‘%s’ %}

{% assign diffSeconds = endDate-beginDate %}
{% assign diffDays = diffSeconds/3600/24 %}

{{ diffDays | integer }}

Let me know if this solved it :smiley: