I did see a similar post but no resolution.
I have a Memory tag that calculates the production date. For our facility the production date starts at 5:00 am, so between midnight and 5:00 am the production date is the previous day. My expression for the tag is:
If((getHour24({[System]Gateway/CurrentDateTime})>=0) && (getHour24({[System]Gateway/CurrentDateTime})< 5),
addDays(midnight({[System]Gateway/CurrentDateTime}),-1),
midnight({[System]Gateway/CurrentDateTime}))
and it works fine. Tag datatype is DateTime.
In my Perspective project I use that tag to do various calculations, for example, to calculate the first full hour of production, I create a parameter with the expression binding of:
setTime({[default]Memory/Current_Production_Date},6,0,0)
and it works and has been working for months - I use similar calculations in named queries that return correct results.
I’m troubleshooting a different error and I notice that these setTime calls are generating errors:
setTime function expected a 'date' first argument, but got null
Is there something I can do to keep these errors from generating - rewrite the expression?