Hi
Can a calender year be used in a calculation? I want to calculate the age of the director. I’ve taken financial year now, but that is not always correct.
Blockquote
{% assign leeftijd = custom.director.geboortedatum | date:“%Y” %}
{{ period.financial_year-leeftijd | integer }}
Hi Sylvia
You could do the following:
{% input custom.birth.day as:date %}
{% assign birthday_year = custom.birth.day | date:"%Y" %}
{% assign today_year = "now" | date:"%Y" %}
{% assign birthday_month = custom.birth.day | date:"%-m" %}
{% assign today_month = "now" | date:"%-m" %}
{% assign birthday_day = custom.birth.day | date:"%-d" %}
{% assign today_day = "now" | date:"%-d" %}
{% assign diff = 0 %}
{% if (today_month-birthday_month) > 0 %}
{% assign diff = 1 %}
{% elsif (today_month-birthday_month) == 0 and (today_day-birthday_day) >= 0 %}
{% assign diff = 1 %}
{% endif %}
{{ INT(today_year-birthday_year-diff) }}
By using now
as a keyword, the day of today is used. If you want to use the date of the current period instead, you can use period.start_date
or period.end_date
depending on which moment in the period you want to check.
Hope this helps.
Kind regards
Sam
Yes, this seems to work!
Thx!