If statement with fixed date

Hi,

I stuk with an If statement:
If statement should do the following:

“if” detailwagen.custom.aanschaffingsdatum < 01/01/2018
then
warningtext …

in code :

{% assign oude_regeling_PW = '01/01/2018' | as:date %}

...
code for fori loop
...


{% if detailwagen.custom.aanschaffingsdatum < oude_regeling_PW %}
  {% ic %}{::warningtext as="hover"}
  {% t "aanschaffing wagen voor 01/01/2018:" %}
  <br>
  {% t "_**Minimum**_ fiscale aftrek = 75%" %}
  <br>
  {% t "fiscale aftrek brandstof = 75%" %}
  {:/warningtext}{% endic %}

So the “assign” should have the value of a fixed date. in this case the date is 01/01/2018
or shorter the if statement shoud check if the given inputfield is < than 01/01/2018

how should I formulate this in code?

Hi Alexander

In order to make date comparisons work correctly you’ll need to define them in a variable like this:

{% assign oude_regeling_PW = "01/01/2018" |  date:"%Y-%m-%d" %}

{% fori detailwagen in custom.wagens %}
  {% input detailwagen.aanschaffingsdatum as:date %}
  {% assign aanschaffingsdatum_PW = detailwagen.aanschaffingsdatum |  date:"%Y-%m-%d" %}
  
  {% if aanschaffingsdatum_PW < oude_regeling_PW  %}
    {% ic %}{::warningtext as="hover"}
    {% t "aanschaffing wagen voor 01/01/2018:" %}
    <br>
    {% t "_**Minimum**_ fiscale aftrek = 75%" %}
    <br>
    {% t "fiscale aftrek brandstof = 75%" %}
    {:/warningtext}{% endic %}
  {% endif %}
{% endfori %}

Kind regards
Wouter