# Swing Shift Production

**URL:** <https://forum.inductiveautomation.com/t/swing-shift-production/17605>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [April 4, 2018, 7:20pm UTC](https://forum.inductiveautomation.com/t/swing-shift-production/17605 "2018-04-04T19:20:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![BLStone77](https://avatars.discourse-cdn.com/v4/letter/b/db5fbb/32.png) [@BLStone77](https://forum.inductiveautomation.com/u/BLStone77)\
**Post date:** [April 4, 2018, 7:20pm UTC](https://forum.inductiveautomation.com/t/swing-shift-production/17605/1 "2018-04-04T19:20:38Z")

</div>

so I have a day shift that is from 4AM to 3:30PM which updates production through transaction group at 3:35PM.  
Swing shift starts the same day at 4PM and ends the next day at 2:30AM and updates through transaction group at 2:35AM. So question is how to get the swing production that is updated on the next day to show on the actual day the shift started?  
Almost zero scripting experience so struggling with this one.

---

<div class="post-metadata">

**Author:** ![BLStone77](https://avatars.discourse-cdn.com/v4/letter/b/db5fbb/32.png) [@BLStone77](https://forum.inductiveautomation.com/u/BLStone77)\
**Post date:** [April 4, 2018, 7:22pm UTC](https://forum.inductiveautomation.com/t/swing-shift-production/17605/2 "2018-04-04T19:22:52Z")

</div>

Also using this on a calendar view

---

<div class="post-metadata">

**Author:** ![bfuson](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bfuson/32/4597_2.png) [@bfuson](https://forum.inductiveautomation.com/u/bfuson)\
**Post date:** [April 4, 2018, 7:51pm UTC](https://forum.inductiveautomation.com/t/swing-shift-production/17605/3 "2018-04-04T19:51:25Z")

</div>

I usually avoid transaction groups and opt for a scripted database logging approach myself.

I like to make my own time shared scripting module for functions like this.  
Something like:

```auto
def getProductionStartingDay(datetime=None):
    if datetime == None:
        datetime = system.date.now()
    hours = system.date.getHours(datetime)
    if hours < 4:
        return system.date.addDays(datetime, -1)
    else:
        return datetime

```

Then you can take the returned datetime and format it to be just the date, or pass it along to a query if the backing table column is of type date and not datetime.
