Date is between


#1

is there a way to do date is between regardless of the year?

I use time is in between as a condition quite frequently. But I wish there was a way to do date is between. And not have to worry about the year. For instance every year between October 1 and October 31.


No YEAR in restriction?
#2

If you’re only worried about the current year, you could use an expression instead of the date picker:

Accounting for a span across December to January would be more tricky, easiest would probably be an OR between a range that ends Dec 31 and a range that starts Jan 1. Don’t use $year + 1 for January, because when January rolls around that expression will evaluate to January of the following year. This example would work for a date range of December 12 to February 3:

03 PM

You can play around with the formatting, I avoided the 05/17/2017 format since the ordering of mm/dd dd/mm is not global. Unfortunately a universal format like yyyy-mm-dd does not work.


#3

why not do this? its not meant to be locale independent but then it does not need to be because it only runs on your hub which is in one location. :slight_smile:

if Date is between date(format("%d/%d/%d", 12, 25, $year)) and date(format("%d/%d/%d", 1, 7, ($year+1)))


#4

That will not work in January since $year + 1 is always next year relative to today.


#5

why would add $year+1 why the date range sits entirely in one year?

if Date is between date(format("%d/%d/%d", 01, 10, $year)) and date(format("%d/%d/%d", 1, 17, $year))


#6

You wouldn’t add one within the same year… :confused: no need to increase confusion here, the original answer is sufficient. Using $year + 1 for a range starting in December and ending in January does not work in January.


#7

i see what you mean. let me also think about that, we need a simple solution to this that works universally with any date.


#8

Yeah… there are other ways to structure expressions for this kind of thing but I’m not sure if there is anything that doesn’t require dipping into an expression. If you wanted to represent for example December 15 – January 15 in a single condition you could use not between instead but that seems more confusing to maintain:

I’ll update the original answer with a screenshot to make the Dec-Jan solution a bit more clear.


#9

If you want your piston to be a little clearer (opinion), you can define each date as a function in the piston variables.

image