Ignition v8.1.39
MS SQL Server Express v16.0.1000.6
I've been doing some testing using SQL Express and I am seeing a small discrepancy and I'm not sure if it is caused by something I am doing.
Our project requires me to query Ignition Historian for values and merge them into another database table.
In my table. there are three columns I use to determine update/insert in the merge query.
Columns equipmentId [int], eventId [int], eventBegin [datetime2(3)]
.
The merge will update two other columns eventEnd [datetime2(3)], eventDuration [float]
if a match is found in the three columns above.
I am using system.tag.queryHistory
to get the data for the merge. The data is being queried using an RTP whose gateway is in a different timezone. In production, the query will be querying the local Historian, not an RTP.
I get the tstamp from historian as java.util.Date
and convert it to a java.sql.Timestamp
.
I do this for a mass number of values, assemble them, and send to a named query as a query string to do the merge.
The mismatch I am seeing is in the milliseconds. Any tstamp that has a leading zero in it's ms, the zero is removed and placed at the end.
Any other combination it seems to be fine.
For example:
Values to Insert
[8, 2, 2024-11-18 04:41:02.039]
[8, 5, 2024-11-18 08:32:12.095]
[8, 2, 2024-11-18 08:39:17.019]
Values In Table
equipId | eventCode | eventBegin
8 | 2 | 2024-11-18 04:41:02.390
8 | 5 | 2024-11-18 08:32:12.950
8 | 2 | 2024-11-18 08:39:17.190
I thought maybe it was because of the column type. I changed the column from datetime
to datetime2(3)
last week because the rounding was causing inserts that should have been updates. I did a query to see if there were any rows that had a leading zero. Out of 513000 rows, less than 1% of the rows do. However, they are all .000
.
In the DB Query Browser, I can write an update query and set it with a leading 0 just fine.