# DateTime Input and Project Library script error

**URL:** <https://forum.inductiveautomation.com/t/datetime-input-and-project-library-script-error/57568>\
**Category:** Ignition\
**Tags:** scripting, perspective\
**Created:** [March 24, 2022, 12:16am UTC](https://forum.inductiveautomation.com/t/datetime-input-and-project-library-script-error/57568 "2022-03-24T00:16:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [March 24, 2022, 12:16am UTC](https://forum.inductiveautomation.com/t/datetime-input-and-project-library-script-error/57568/1 "2022-03-24T00:16:43Z")

</div>

If I call my project library script `def shiftGenerator(startDate, shiftPattern):` from the Script Console like this,

```auto
	startDate = system.date.addDays(system.date.now(), -1)	# Yesterday for testing.
	shiftPattern = [...]
	shiftCalcs.shiftCalcs.shiftGenerator(startDate, shiftPattern)

```

it works.

When I call it from an Expression Binding like this,

```auto
runScript(
	"shiftCalcs.shiftCalcs.shiftGenerator", 
	2000,	// 2 second update for testing. 
	{session.custom.datePicker},
	{view.params.config.shiftPattern} 
)

```

The problem seems to be caused by whatever format the datePicker session variable is stored in. _datePicker_ is generated by a DateTime Input component which has a simple (bidirectional) property binding from it’s `props.value` to the session custom property `session.custom.datePicker`.

It seems to choke with an `Error_ExpressionEval` error when `startDate` is passed to this function:

```auto
def addShiftStartTime(timestamp, time_str, nextDay):
	# First shift usually starts at 7 a.m. or 8 a.m.
	# timestamp is midnight of the calendar start day.
	# time_str is the shift start in "hh:mm" format.
	# nextDay signals if the start of the third shift is after midnight.
	h, m = time_str.split(':')
	newDate = system.date.addHours(timestamp, int(h))	# Add on the hours,
	newDate = system.date.addMinutes(newDate, int(m))	# and the minutes,
	if nextDay:											
		newDate = system.date.addDays(newDate, 1) # and another 24 hours.
	return newDate

```

Can anyone suggest some debug procedures?

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [March 24, 2022, 11:27am UTC](https://forum.inductiveautomation.com/t/datetime-input-and-project-library-script-error/57568/2 "2022-03-24T11:27:14Z")

</div>

Some progress. Changing  
`d = system.date.midnight(system.date.toMillis(startDate))`  
to  
`d = system.date.midnight(startDate)`  
in my function seems to work for both the Script Console and the Expression Binding.
