# OEE Production start scripting

**URL:** <https://forum.inductiveautomation.com/t/oee-production-start-scripting/91474>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [June 6, 2024, 1:14pm UTC](https://forum.inductiveautomation.com/t/oee-production-start-scripting/91474 "2024-06-06T13:14:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![AkshayP](https://avatars.discourse-cdn.com/v4/letter/a/b487fb/32.png) [@AkshayP](https://forum.inductiveautomation.com/u/AkshayP)\
**Post date:** [June 6, 2024, 1:14pm UTC](https://forum.inductiveautomation.com/t/oee-production-start-scripting/91474/1 "2024-06-06T13:14:09Z")

</div>

I am struggling to start the production in midnight shift on OEE screen. Please see below scripting for the start production button for midnight shift. When we pressed the start production button it is not starting the production and also it is not giving me any error message. Please find below the scripting. Any help would be appreciated.

```python
target = system.date.now()
date1 = windows.rootContainer.getComponent('DateDropdown').selectedLabel

#elif event.source.parent.getComponent('ShiftDropdown').selectedLabel == "MIDNIGHT":
		 
	production_status = "Production"
	params = {"Production_Marker":production_status, "Hour_Record": 23, "DateSelected":event.source.parent.getComponent('DateDropdown').selectedLabel}		
	system.db.runNamedQuery("Bread/ProdMarker", params)
	
	nhour = " 23:03"
	time = system.date.parse(date1 + nhour , "dd/M/yyyy HH:mm")
	diff1 = target.getTime() - time.getTime()
	diffmin = (diff1/(60000))
	if diffmin >= 485:	
		params = {"HourRecord":23, "DateSelected":date1}		
		productionstatus = system.db.runNamedQuery("Bread/Grab_ProdMarker_and_tstamp", params) 
		timestamp =system.date.format(productionstatus.getValueAt(0, 1),"yyyy-MM-dd HH:mm")				
		Production_day = 1
		params2 = {"Production_Day":Production_day,"t_stamp":timestamp} 
		system.db.runNamedQuery("Bread/Production_Day", params2)

```

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [June 6, 2024, 1:47pm UTC](https://forum.inductiveautomation.com/t/oee-production-start-scripting/91474/2 "2024-06-06T13:47:12Z")

</div>

First off, it might be a little less verbose

```python
diffmin = system.date.minutesBetween(time, target)

```

Next, add a print statement to check the `diffmin` value, make sure it is what you expect. Really, you should print all of your variables and make sure they are correct

```python
print diffmin
if diffmin >= 485:
...

```

If that does not solve your problem, check your queries.
