I've been using this logic for years, worked well so far, I think this is similar to what you posted (and deleted) last week.
Yeah, very similar. My issue is that some of my customers don't have the equipment powered up 24/7, so I wanted something that would determine the correct state for ST768 no matter when it was executed. So that's why the inequalities in the MATH vs. equality tests, and the reason for the $ST0 on the permissive, so it gets run once on power up. I do the same thing for stuff intended to run once a day, say at midnight. I record the last date on which it ran, and part of the enable is $Now.Day != LastRunDate. Then if the PLC is off at midnight or whatever the designated run time is, the stuff still gets done, pending any other permissives.
Today's is identical to last week's except the the last OR expression was actually true AFTER the first Sunday in November, rather than before. So I knew it was wrong, but didn't have the time to think through the exact fix. Change the >= to <? <=? Adjust +/- the offset that corrects for MIN(Day) == 1, but MIN(DoW) == 0? So I took it down till I could think it through. Turns out I just needed to change the >= to <.
I'm a MATH box monkey. Like the old saying goes, When the only tool you have is a MATH box, every problem is a math problem!
