{% set staticDate = "2021-03-01T00:00:00+0000"|strtotime("yyyy-MM-dd'T'HH:mm:ssZ") %}{# the date you're checking against #}
{% set dynmDate = row["anticipated-build-completion"] %} {# your dynamic date #}
{% if dynmDate|between_times(staticDate, 'days') >= 1 %} {# Check using between times #}
{# if the date is before teh staticDate #}
{% elif %}
{# if the date is after teh staticDate #}
{% endif %}
I wonder if the mutating/formatting of the data is getting in the way.
As a best practice we try to avoid mutating data until the last possible time (usually displaying it). We do this because mutating data back and forth can make it hard to track and understand the state of the data. Also when comparing a dynamic value with a static value we try to match the static value's format to that of the dynamic.
To test if this might be the case try printing the variable and comparing manually:
{{ row["anticipated-build-completion"] }}
Basically take a look at that output and then try to modify the static date format you're checking against.
{% set staticDate = "2021-03-01T00:00:00+0000"|strtotime("yyyy-MM-dd'T'HH:mm:ssZ") %}{# the date you're checking against #}
{% set dynmDate = row["anticipated-build-completion"] %} {# your dynamic date #}
{% if dynmDate|between_times(staticDate, 'days') >= 1 %} {# Check using between times #}
{# if the date is before teh staticDate #}
{% elif %}
{# if the date is after teh staticDate #}
{% endif %}
@ben-duchy the problem is because you are formatting it, then trying to use math/logic on a formatted date. Instead, you should try using the unixtimestamp equivalant for the date. This way you are just comparing two numbers with each other so the computer can understand what you're doing... so something like this:
{% if unixtimestamp(row.datetimeobject) < 1614556800 %}
I'm a date before March 1st 2021!
{% endif %}
Hi @stefen, great idea, I wasn't even aware of this method.
Unfortunately I can't get it to work correctly as its pulling in all rows to show 'A content' or 'B content' depending on the less / more arrow used. It's not filtering them!