How to use logic operators on a date?

Dear,

I believe it is interesting to know how to use logic formula’s on a date.
Suppose I want to know if February 29 is part of my accounting period.

I tried to program it with the following code:
´´´
{% capture first_date %}{% period.year_start_date as date: %d/%m/%y %}{% endcapture %}
{% capture last_date %}{% period.year_end_date as date: %d/%m/%y %}{% endcapture %}

{% if first_date <= ‘29/02/16’ and last_date >= ‘29/02/16’ %}{% assign z = 0 %}{% else %}{% assign z = 1 %} {% endif %}
´´´
However when I use this code when my period is 01/01/17-31/12/17 I still get z = 0.
This is quite bothering me.

Someone an idea here?

Kind regards,

Glenn

Hello @GMOONS,

Could you please try to change the {% %} to {{ }} in the following elements that you capture in your code:
{% period.year_start_date as date: %d/%m/%y %}
{% period.year_end_date as date: %d/%m/%y %}

Your code should look like:

{% capture first_date %}{{ period.year_start_date as date: %d/%m/%y }}{% endcapture %}
{% capture last_date %}{{ period.year_end_date as date: %d/%m/%y }}{% endcapture %}

{% if first_date <= '29/02/16' and last_date >= '29/02/16' %}{% assign z = 0 %}{% else %}{% assign z = 1 %} {% endif %}

Kind regards,

Mathias