# Shift patterns in schedules configuration

**URL:** <https://forum.inductiveautomation.com/t/shift-patterns-in-schedules-configuration/70157>\
**Category:** Ignition\
**Created:** [February 22, 2023, 9:16am UTC](https://forum.inductiveautomation.com/t/shift-patterns-in-schedules-configuration/70157 "2023-02-22T09:16:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![DOH](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/doh/32/44079_2.png) [@DOH](https://forum.inductiveautomation.com/u/DOH)\
**Post date:** [February 22, 2023, 9:16am UTC](https://forum.inductiveautomation.com/t/shift-patterns-in-schedules-configuration/70157/1 "2023-02-22T09:16:13Z")

</div>

Hello

I'm having some trouble configuring the schedules function on the gate to capture the required shift patterns.

Shift = A (2 Days of day shift 7:00am to 7:00 pm followed immediately by 2 days of nights 7:00pm to 7:00 am)  
Shift = B (2 Days of day shift 7:00am to 7:00 pm followed immediately by 2 days of nights 7:00pm to 7:00 am)  
Shift = C (2 Days of day shift 7:00am to 7:00 pm followed immediately by 2 days of nights 7:00pm to 7:00 am)  
Shift = D (2 Days of day shift 7:00am to 7:00 pm followed immediately by 2 days of nights 7:00pm to 7:00 am)

 ![rota](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/6/36de851d37c4640462fbb766b222b694a11581e4.png)

Looking at the above rota when starting on the 2nd of January shift D are on day the 2nd and 3rd and than on nights the 4th and 5th into the morning of the 6th and so on for all the shifts.

I have tried to set up shifts in a number of ways. First I created just a shift A,B,C,D each configured to the relevant dates but this quickly seems to go out of sequence.

I than attempted to create a day and night shift for each group e.g. Shift\_A\_days , Shift\_A\_Nights with the intention to create a composite shift based on days and nights but I am having a similar issue were in multiple shifts seem to be active at once. It seems to be following the calendar week repeating on the same days of each week rather than being offset as the weeks move on.

 ![days](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/6/56c67dd81163455bbf0dc694297e9c1005ead495.png)

 ![nights](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/5/4598996c4c0fed3173d3b7038e42cb02a1dbe338.png)

Looking at the coloured rota above if a shift was split into days and nights  
• On days they would be on for 2 days and then off for 6 e.g. start days on the 6th of January finish on the 7th and then next on days on the 14th January  
• On nights they would be 3 days on and then 4 days off e.g starting nights on the 8th of January and finishing nights the morning of 10th of January next returning to nights on the 16th of January

I am assuming I'm missing something obvious here and would greatly appreciate any help

Thanks in advance

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 22, 2023, 12:27pm UTC](https://forum.inductiveautomation.com/t/shift-patterns-in-schedules-configuration/70157/2 "2023-02-22T12:27:47Z")

</div>

When you have complex patterns, you generally need a complex solution. See this topic for working code that implements a generic solution for _ **any** _ repeating shift schedule:

> [@Script for periodically changing shift time](https://forum.inductiveautomation.com/t/script-for-periodically-changing-shift-time/51058/3):
>
> Hi Berkay, I like to solve this kind of problem with a smart database, like PostgreSQL, where I can define a pattern and repeat it with table generating functions. I tweaked one of my implementations to serve as an example: create table shift\_schedules (shift\_id serial, shift\_name varchar(255), refdate date, repeat int, tzname varchar(255), primary key (shift\_id)); insert into shift\_schedules (shift\_name, refdate, repeat, tzname) values ('Berkay Cinar 3wk', '2021-07-26', 21, 'America/Ne…

If you aren't using PostgreSQL, you will have to substitute other ways to use table-returning functions. (Good luck with that.)

---

<div class="post-metadata">

**Author:** ![crees](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@crees](https://forum.inductiveautomation.com/u/crees)\
**Post date:** [February 22, 2023, 1:47pm UTC](https://forum.inductiveautomation.com/t/shift-patterns-in-schedules-configuration/70157/3 "2023-02-22T13:47:34Z")

</div>

Looking at your schedule setup, you don't actually repeat week 1 until week 9. Based on this, you likely need to create basic schedules for Shift A Week 1, Week 2 ... 9, then a composite schedule that grabs all 9 schedules for Shift A.

Each schedule would be setup to repeat "Weekly", with 1 week on, 8 weeks off. Pretty complicated.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 22, 2023, 1:50pm UTC](https://forum.inductiveautomation.com/t/shift-patterns-in-schedules-configuration/70157/4 "2023-02-22T13:50:13Z")

</div>

> [@crees](#):
>
> Pretty complicated.

Yup. Unless there's a solution in hand that can take the 8-week pattern and replicate it for you on demand.

But in this case, the repeat is 8 days. Two days on, six days off. The schedule should select "all days", not any particular weekdays. And uncheck "observe holidays".

---

<div class="post-metadata">

**Author:** ![DOH](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/doh/32/44079_2.png) [@DOH](https://forum.inductiveautomation.com/u/DOH)\
**Post date:** [February 22, 2023, 3:33pm UTC](https://forum.inductiveautomation.com/t/shift-patterns-in-schedules-configuration/70157/5 "2023-02-22T15:33:42Z")

</div>

Click : 💡

Basic mistake realized i hope. Thank you very much for the quick replies.

> Blockquote But in this case, the repeat is 8 days. Two days on, six days off. The schedule should select "all days", not any particular weekdays. And uncheck "observe holidays".

I was assuming that system would shift the days as the weeks moved forward instead of considering that all days should be selected and use the repeating function would  
to shift the days.

At least for the day shift this seems to have resolved the issue as i have selected the options **pturmel** suggested and the schedule "active now" indicator at least looks correct for today.

I have updated the night shift with shift time 19:00 - 07:00 which I'm not sure will work correctly but if not i can create a couple a night shift - morning - night shift pattern and make a composite from that.

failing that I will try a variant of your table option **pturmel** , we are using MySQL

Thanks for the help so far ,

**EDIT :**  
As a test of the idea I have created 4 shifts c1 to c4  
c1 = 19:00 -24:00 starting 13/01/23  
c2 = 00:00 -07:00 starting 14/01/23  
c3 = 19:00 -24:00 starting 14/01/23  
c4 = 00:00 -07:00 starting 15/01/23

 ![CompShifts](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/d/cdd587c71e245efbb07e6a759fe3fde4a09ad713.png)

Than combined these to make a pair of composite single shift across a night and day, than from there make a composite shift  
Comp1 =  
c1 = 19:00 -24:00 starting 13/01/23  
c2 = 00:00 -07:00 starting 14/01/23

Comp2 =  
c3 = 19:00 -24:00 starting 14/01/23  
c4 = 00:00 -07:00 starting 15/01/23

CompTotal = Comp1 + Comp2

 ![comp2](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/3/135a22befaceecf6a331f83f40f19cfbd3f5a0b8.png)

I will send an update when I have news

---

<div class="post-metadata">

**Author:** ![DOH](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/doh/32/44079_2.png) [@DOH](https://forum.inductiveautomation.com/u/DOH)\
**Post date:** [March 8, 2023, 9:58pm UTC](https://forum.inductiveautomation.com/t/shift-patterns-in-schedules-configuration/70157/6 "2023-03-08T21:58:23Z")

</div>

Apologies late getting back to this. The issue as I mentioned above was with misunderstanding "all days" setting. Once "all days" setting was enabled (rather than a specific day aligning to start date) it was not difficult to configure. Days are a simple repeating 07:00-19:00 , 2 days on 6 off .Nights are a composite of evenings(19:00 -24:00 2 days on 6 off) and mornings(00:00 - 07:00 2 days on 6 off) and the shift becomes a composite of days and nights.

Thanks for the help with this
