# Strange behaviour on a specific date

**URL:** <https://forum.inductiveautomation.com/t/strange-behaviour-on-a-specific-date/87621>\
**Category:** Ignition Early Access\
**Created:** [March 20, 2024, 12:43pm UTC](https://forum.inductiveautomation.com/t/strange-behaviour-on-a-specific-date/87621 "2024-03-20T12:43:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vincent.devillers](https://avatars.discourse-cdn.com/v4/letter/v/5daacb/32.png) [@vincent.devillers](https://forum.inductiveautomation.com/u/vincent.devillers)\
**Post date:** [March 20, 2024, 12:43pm UTC](https://forum.inductiveautomation.com/t/strange-behaviour-on-a-specific-date/87621/1 "2024-03-20T12:43:15Z")

</div>

I'm investigation a strange behaviour only happening once a year ( on the 31th of december)

We have three Ignition servers running at a customer, all three have been returning a strange date on the 31th of december in a mySQL database used to log data  
the timestamp for the date is extracted using sytem.date.now,  
system.date.format is used to format the date for the database

**Ignition SCADA Version**  
Ignition version 8.1.29  
Operating system : Linux  
Timezone : Europe/Brussels

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/f/1ffd7f1a2631a032e0d016f8d72b974b8e763cd8.png)

**Source code used**

```auto
def writeQuery_mysql(Variable_name):

	Datetime = (system.date.format(system.date.now(),"YYYYMMddHHmmssSSS"))[0:19]
	State = stateGantryMysql(Variable_name)
	row = {"Dt": Datetime, "Variable_name": Variable_name, "State": State}
	try:
		if State != '':
			system.db.runNamedQuery("logbook/rss_logbookmysql",row)
	except:
		pass

```

**named query**  
INSERT INTO logboekmysql (Datetime, Variable\_name, State) VALUES (:Dt, :Variable\_name, :State);

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/6/06ee6a0a63cebbe7339d144899ae71fc8333092f.png)

**Example of logged data**  
the data below has been logged on the 31th of december 2023

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/6/b6139b514ddb9d8567b371de2219839b7a8ba819.png)

**behaviour detected**  
the datetime returned on the 31 first of december 2023 has been logged one year in the future.  
All logged records on other date times are correct. All other loggings ar correct

**question**  
is it possible that system.date.now() is returining a wrong value on the 31th of december?

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [March 20, 2024, 12:49pm UTC](https://forum.inductiveautomation.com/t/strange-behaviour-on-a-specific-date/87621/2 "2024-03-20T12:49:23Z")

</div>

Don't know exactly but what I can tell you is you should turn your `Dt` named query parameter to a DataType of `DateTime` and then in your script do `Datetime = system.date.now()` instead of formatting it as a string.

And if your database is not using a datetime type for that column, do so.

Use the appropriate datatypes and these sort of issues won't happen. I can't say for sure what is going here, but I would say using datetimes appropriately probably resolves it.

I do not believe that `system.date.now()` gives a wrong date on a particular day of the year.

---

<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:** [March 20, 2024, 12:59pm UTC](https://forum.inductiveautomation.com/t/strange-behaviour-on-a-specific-date/87621/3 "2024-03-20T12:59:38Z")

</div>

You are using capital `YYYY` in your format. You probably should be using lower-case `yyyy`. See why here:

> **[Data Type Formatting Reference | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/appendix/reference-pages/data-type-formatting-reference)**
>
> This page formatting patterns for dates, numbers, and strings.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 20, 2024, 3:45pm UTC](https://forum.inductiveautomation.com/t/strange-behaviour-on-a-specific-date/87621/4 "2024-03-20T15:45:10Z")

</div>

ISO week-years strike again:

[![](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/6/f6d53453c99ff042095fb320f7567456bdd7c50d.jpeg "Why 2020 Started On December 30th") ](https://www.youtube.com/watch?v=D3jxx8Yyw1c)

---

<div class="post-metadata">

**Author:** ![vincent.devillers](https://avatars.discourse-cdn.com/v4/letter/v/5daacb/32.png) [@vincent.devillers](https://forum.inductiveautomation.com/u/vincent.devillers)\
**Post date:** [April 6, 2024, 4:10pm UTC](https://forum.inductiveautomation.com/t/strange-behaviour-on-a-specific-date/87621/5 "2024-04-06T16:10:48Z")

</div>

Yest, that is likely the cause of the problem.  
I did not write this code, so I was not suspecting there could be a yyyy versus a YYYY  
Thank you, very much
