# Calculate with date

HI

I was trying to calculate with dates, but I had a problem. I need to have book year + 1 day.
I had it first like this,`

{% assign current_date = custom[account.number].aanslagjaar %}
{% assign date_days = current_date | date:"%d/%m/%y" %}
{% assign year = current_date | date:"%Y" %}{% assign year_5 = year | plus:5%}
{% assign day = current_date | date: “%d” %}{% assign day_16 = 1%}
{% assign month = current_date | date: “%m” %}{% assign month_0 = month | plus:1%}
{% capture date %}{{day_16}}/{{month_0}}/{{year_5}}{% endcapture%}
|{{date}}’

but when I have a bookyear 31/12/2013, he gives 01/13/2018.
So I put an if, but it doesn’t work.

{% assign current_date = custom[account.number].aanslagjaar %}
{% assign date_days = current_date | date:"%d/%m/%y" %}
{% assign day = current_date | date: “%d” %}{% assign day_16 = 1%}
{% assign maand = current_date | date: “%m” %}
{% assign year = current_date | date:"%Y" %}
{% if maand = 12 %}
{% assign year_5 = year | plus:6%}
{% assign month_0 = 1%}
{% else %}
{% assign year_5 = year | plus:5%}
{% assign month_0 = maand | plus:1%}
{% endif %}
{% capture date %}{{day_16}}/{{month_0}}/{{year_5}}{% endcapture%}
|{{date}}’

Just replace {% if maand = 12 %} by {% if maand == 12 %} and it should be fine.

Kind regards
Sam

PS: Nice code

1 Like

{% if maand < ‘12’%}
{% assign year_5 = year | plus:5%}
{% assign month_0 = maand | plus:1%}
{% else %}
{% assign year_5 = year | plus:6%}
{% assign month_0 = 1%}
{% endif %}
{% capture date %}{{day_16}}/{{month_0}}/{{year_5}}{% endcapture%}

now it works Thanks!
Best regards!
Liesbet