Time Range Logic Using Date/Time & Sunrise/Sunset

Looking at the attached, trying to have a TRUE condition after 2300 and before sunrise-15 +1day. Presume this logic is failing because both times occur on different days? Poked around and didnt see any options for specifying a day offset.

Thinking I would need to do this differently… by setting the logical comparison to OR. By being unable to use lets say an EPOC time representation across 2 different days, the only option is to use the boundaries of what I presume would be MIDNIGHT same day.

Will see if this works, but would my logic be correct in this?

In my PLEG Days I used NOT to manage conditions that crossed midnight.
for example, NOT (0900-2100) equals 2100 to 0900 in the AM the next day.
Might take some time to get your head around that but it works.

As soon as you cross midnight the condition “after 2300” is no longer true. Try making this a range like between 2300 and 0800 and see if that works. Also, try between sunset and sunrise with the offsets you need.

1 Like

Both @zedrally and @TomD have good information. Either approach is workable.

The important piece of information you need to keep in mind is that all time-only (no date) conditions expire at midnight, as @TomD said. So there are two approaches in the comments that you can take:

Going first with @TomD’s rule, “after 2300” means “between 2300 and midnight”. Likewise “before sunrise” means “between midnight and sunrise”. That means there are two spans of time here, one before midnight and one after, than can be joined into one. This would be done with an “OR” on a containing group.

The group will be true in either (OR) of the two spans of time, and since they are contiguous, the group will be true from 11pm to sunrise the next day (uninterrupted).

Approaching it from @zedrally’s perspective is also straightforward. If you want something to happen after 11pm and before sunrise, you want it to happen when the time is NOT after sunrise AND before 11pm:

Either approach will work.

Have a friend staying at my place, so have been using him as a test subject for one of the bedrooms, hence how I came across this. Made an incorrect assumption about sunrise being the next occurrence, if it has already passed, but this was incorrect as things are within the current days boundary. As mentioned in my post originally, ended up testing / using the OR option and it works just fine. Thanks everyone!

1 Like