Hello,
I am struggling through my first Ignition project and have a problem which I somehow can't get to grips with.
I call an MSSQL stored procedure from a script. I read a label.text which contains a German time string, e.g. 10.04.2025 10:00:00. I convert this into a Date object. When I pass this Date object to the StoredProcedure as a timestamp, something always adds an hour to it, which corresponds to the current deviation from UTC, then 2 hours from March 30th. If I pass it as a string to the stored procedure and convert it in the SQL server then it works perfectly. Is there a way to use the datetime conversion without this phenomenon?
My script code:
eventId = self.view.custom.selectedEventId
itemId = self.view.custom.selectedItemId
planStart = self.parent.getChild("columnStartDateTime").getChild("label").props.text
planStart = converter.dateTimeConverter(planStart)
call = system.db.createSProcCall("dbo.sp_U_Schedule", "ProdAppDB")
call.registerInParam("orderNumber", system.db.NVARCHAR,eventId)
call.registerInParam("equipmentId", system.db.BIGINT,itemId)
call.registerInParam("planstart", system.db.TIMESTAMP,planStart)
call.registerOutParam("responseMessage", system.db.NVARCHAR)
call.registerOutParam("responseCode", system.db.INTEGER)
system.db.execSProcCall(call)
My dateTimeConverter:
def dateTimeConverter(stringToTime):
import datetime
responseDateTime = datetime.datetime.strptime(stringToTime , '%d.%m.%Y %H:%M:%S')
return responseDateTime
Thanks for your support