macjeff Posted December 6, 2021 Posted December 6, 2021 I have things that run on the Third Wednesday of the month or others like the 2nd Friday of the month I have been using this program to calculate week of month WeekofTheMonth - [ID 0282][Parent 0219] $WeekofTheMonthTemp = [Current Day of Month] $WeekofTheMonthTemp -= 1 $WeekofTheMonthTemp /= 7 $WeekofTheMonthTemp += 1 $WeekofTheMonthTemp Init To $WeekofTheMonthTemp $WeekOfTheMonth = $WeekofTheMonthTemp and then I say day is (Monday, Tuesday, etc) using the ISY TimeData Nodeserver and the week number is (whatever I need) Is there a better way to do this? Jeff
MrBill Posted December 6, 2021 Posted December 6, 2021 (edited) Yes..... It's basically the same thing... But I use this program by @kclenden to set a number of date variables: Set Date Variables - [ID 0104][Parent 0126] If Time is 12:00:00AM Then // Determine Day of Week $sISY.DayOfWeek = [Current Day of Week] $sISY.DayOfWeek Init To $sISY.DayOfWeek $iISY.DayOfWeek = $sISY.DayOfWeek $iISY.DayOfWeek Init To $sISY.DayOfWeek // Determine the Month $sISY.DayOfMonth = [Current Day of Month] $sISY.DayOfMonth Init To $sISY.DayOfMonth $iISY.DayOfMonth = $sISY.DayOfMonth $iISY.DayOfMonth Init To $sISY.DayOfMonth // Determine the Month of the Year $sISY.MonthOfYear = [Current Month (Jan=1, Feb=2, etc.)] $sISY.MonthOfYear Init To $sISY.MonthOfYear $iISY.MonthOfYear = $sISY.MonthOfYear $iISY.MonthOfYear Init To $sISY.MonthOfYear // Determine the Week of the Month $iISY.WeekOfMonth = $sISY.DayOfMonth $iISY.WeekOfMonth -= 1 $iISY.WeekOfMonth /= 7 $iISY.WeekOfMonth += 1 $iISY.WeekOfMonth Init To $iISY.WeekOfMonth $sISY.WeekOfMonth = $iISY.WeekOfMonth $sISY.WeekOfMonth Init To $iISY.WeekOfMonth // Create Month.Day Combo $iISY.Date_Scratchpad = $iISY.DayOfMonth $iISY.Date_Scratchpad /= 100 $iISY.Date_Scratchpad += $iISY.MonthOfYear $iISY.MMDD = $iISY.Date_Scratchpad $iISY.MMDD Init To $iISY.Date_Scratchpad $sISY.MMDD = $iISY.Date_Scratchpad $sISY.MMDD Init To $iISY.Date_Scratchpad Else - No Actions - (To add one, press 'Action') I re-paste the program rather than just linking to the original which can be found below because there is a minor change "Week of the month" calculations. This version uses the i or Integer version of the variable for inline calulations, then copies the value to the state variable. The original used the state variable for inline calculation which results in false triggers of other programs for intermediate calculations. Why set both state and integer variables for each value? A state variable acts as a TRIGGER in an if statement, conversely an integer variable acts a FILTER in an If statement. Original thread: Edited December 6, 2021 by MrBill
larryllix Posted December 6, 2021 Posted December 6, 2021 (edited) Yes. no access to my ISY right now but. If Wednesday and day of month >= 15 and day of month less than or equal to 21 Then it's the third Wednesday of the month I would use my technique using created variables to do the same easier. $sISY.MM.DD This technique was posted a few years ago. Edited December 6, 2021 by larryllix
Recommended Posts