How do I make an if statement depending on the day? (for every year)


#1

1) Give a description of the problem
I’m stuck trying to make an if statement depending on the day for every year.

2) What is the expected behaviour?
I would like it to be like this:
if day is between 1 to 79 or 355 to 366
then: [code]
else: if day is between 80 to 171
then: [code]
else: if day is between 172 to 263
then: [code]
else: if day is between 264 to 354
then: [code]

3) What is happening/not happening?
I can’t figure out how to do so

4) Post a Green Snapshot of the pistonimage
I have no image, as I have no code.

5) Attach logs after turning logging level to Full
(PASTE YOUR LOGS HERE THEN HIGHLIGHT ALL OF THE LOGS AND CLICK ON THE </> ICON TO FORMAT THEM CORRECTLY)
I have no logs, as I still have no code.

Edit: The code looks messy as I put spaces, but they didn’t show up in the post.

Edit 2: This is for the irrigation, the heating and the cooling.


#2

There are SEVERAL ways you could do this. I might consider a CASE statement. Personally, I would not use nested IF statements. I’m not sure what your daily timing would need to be, but a quick method might be…


#3

my favorite for date ranges is to use expressions:

this way, you know what the dates are :slight_smile:

in my piston, i am using them in the only when block


#4

Both @jkp and @Pantheon have been a massive help! Thanks a lot! :smile: