How can I test if a date is within a certain range using liquid?

Hi there!

I want to test if a date is within a certain range with liquid.

Can anybody advise me how to do this?

I’ve come up with this code snipped, but unfortunately it doesn’t work

{% assign startdate = '2021-01-01' | date: '%s' %}
{% assign enddate = '2021-01-31' | date: '%s' %}
{% if mydate > startdate and mydate
{% assign startdate = '2021-01-01' | date: '%s' %}
{% assign enddate = '2021-01-31' | date: '%s' %}
{% assign mydate = 'now' | date: '%s' %}
{% if mydate > startdate and mydate < enddate %}
1 Like

Thanks a lot!

1 Like

Thank you for update.

1 Like