# Calculating with dates 2.0

**URL:** <https://community.silverfin.com/t/calculating-with-dates-2-0/386>\
**Category:** Templates\
**Tags:** variables, math, register\
**Created:** [September 6, 2017, 2:45pm UTC](https://community.silverfin.com/t/calculating-with-dates-2-0/386 "2017-09-06T14:45:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matthijs](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/matthijs/32/126_2.png) [@Matthijs](https://community.silverfin.com/u/Matthijs)\
**Post date:** [September 6, 2017, 2:45pm UTC](https://community.silverfin.com/t/calculating-with-dates-2-0/386/1 "2017-09-06T14:45:07Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![SamVanEenoo](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/samvaneenoo/32/134_2.png) [@SamVanEenoo](https://community.silverfin.com/u/SamVanEenoo)\
**Post date:** [September 6, 2017, 2:52pm UTC](https://community.silverfin.com/t/calculating-with-dates-2-0/386/2 "2017-09-06T14:52:28Z")

</div>

Hi Matthijs

Do you mean something like this?

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

Kind regards  
Sam

---

<div class="post-metadata">

**Author:** ![Matthijs](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/matthijs/32/126_2.png) [@Matthijs](https://community.silverfin.com/u/Matthijs)\
**Post date:** [September 6, 2017, 2:54pm UTC](https://community.silverfin.com/t/calculating-with-dates-2-0/386/3 "2017-09-06T14:54:33Z")

</div>

yes, but here is the result  
 ![image](https://canada1.discourse-cdn.com/flex030/uploads/getsilverfin/original/1X/4d3faa8c5e2ff02f4eda317e63628845be039614.png)  
he doesn’t calculate with the months…

---

<div class="post-metadata">

**Author:** ![SamVanEenoo](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/samvaneenoo/32/134_2.png) [@SamVanEenoo](https://community.silverfin.com/u/SamVanEenoo)\
**Post date:** [September 6, 2017, 3:12pm UTC](https://community.silverfin.com/t/calculating-with-dates-2-0/386/4 "2017-09-06T15:12:57Z")

</div>

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 😃
