# Problems with datetime

**URL:** <https://forum.inductiveautomation.com/t/problems-with-datetime/102788>\
**Category:** Ignition\
**Tags:** database, scripting, ignition81, perspective\
**Created:** [February 24, 2025, 3:54pm UTC](https://forum.inductiveautomation.com/t/problems-with-datetime/102788 "2025-02-24T15:54:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rene\_Ries](https://avatars.discourse-cdn.com/v4/letter/r/90ced4/32.png) [@Rene\_Ries](https://forum.inductiveautomation.com/u/Rene_Ries)\
**Post date:** [February 24, 2025, 3:54pm UTC](https://forum.inductiveautomation.com/t/problems-with-datetime/102788/1 "2025-02-24T15:54:14Z")

</div>

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:

```python
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:

```python
def dateTimeConverter(stringToTime):
	import datetime
	responseDateTime = datetime.datetime.strptime(stringToTime , '%d.%m.%Y %H:%M:%S')
	return responseDateTime

```

Thanks for your support

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 24, 2025, 4:37pm UTC](https://forum.inductiveautomation.com/t/problems-with-datetime/102788/2 "2025-02-24T16:37:38Z")

</div>

MS SQL Server `datetime` data types are not timezone-aware. If you cannot use `datetime2`, run your Ignition gateway and your SQL Server in UTC (both servers) to avoid these kinds of problems.

(Whatever **else** you do, do not use jython's `datetime` module. Use Ignition's `system.date.*` functions or java's native date/time types.)

---

<div class="post-metadata">

**Author:** ![Rene\_Ries](https://avatars.discourse-cdn.com/v4/letter/r/90ced4/32.png) [@Rene\_Ries](https://forum.inductiveautomation.com/u/Rene_Ries)\
**Post date:** [February 25, 2025, 7:20am UTC](https://forum.inductiveautomation.com/t/problems-with-datetime/102788/3 "2025-02-25T07:20:46Z")

</div>

Thank you for your support. Neither Java nor Python are my normal programming languages, I come completely from the .NET language area and there are relatively simple functions to turn a string into a DateTime format. Why should I not use the Jython datetime module? It is shown everywhere in the forums. What Java alternatives are there that I can simply use in the script?

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [February 25, 2025, 7:43am UTC](https://forum.inductiveautomation.com/t/problems-with-datetime/102788/4 "2025-02-25T07:43:35Z")

</div>

The built-in `system.date.*` functions:

> **[system.date | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-date)**
>
> Date Functions

`system.date.parse` will easily transform a string into a datetime object.

---

<div class="post-metadata">

**Author:** ![Rene\_Ries](https://avatars.discourse-cdn.com/v4/letter/r/90ced4/32.png) [@Rene\_Ries](https://forum.inductiveautomation.com/u/Rene_Ries)\
**Post date:** [February 25, 2025, 11:08am UTC](https://forum.inductiveautomation.com/t/problems-with-datetime/102788/5 "2025-02-25T11:08:12Z")

</div>

Thank you for your support. It works 👍
