# If statement with fixed date

**URL:** <https://community.silverfin.com/t/if-statement-with-fixed-date/1801>\
**Category:** Templates\
**Tags:** dates\
**Created:** [May 27, 2020, 1:07pm UTC](https://community.silverfin.com/t/if-statement-with-fixed-date/1801 "2020-05-27T13:07:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![AlexanderDB](https://avatars.discourse-cdn.com/v4/letter/a/74df32/32.png) [@AlexanderDB](https://community.silverfin.com/u/AlexanderDB)\
**Post date:** [May 27, 2020, 1:07pm UTC](https://community.silverfin.com/t/if-statement-with-fixed-date/1801/1 "2020-05-27T13:07:22Z")

</div>

Hi,

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

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

in code :

```auto
{% 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?

---

<div class="post-metadata">

**Author:** ![Wouter\_Bruynsteen](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.silverfin.com/wouter_bruynsteen/32/1196_2.png) [@Wouter\_Bruynsteen](https://community.silverfin.com/u/Wouter_Bruynsteen)\
**Post date:** [May 28, 2020, 12:43pm UTC](https://community.silverfin.com/t/if-statement-with-fixed-date/1801/2 "2020-05-28T12:43:24Z")

</div>

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
