Skip to main content

Understanding Tag Historian Timestamps

Comments

2 comments

  • Eric Guadalupe

    For SQL Server, we can expand the example to retain milliseconds:

    DATEADD(ms, t_stamp % 1000, DATEADD(s, t_stamp / 1000, '1970-01-01'))

    1
  • Tyler Bennett

    For PostgreSQL...

    Usage: SELECT to_timestamp(t_stamp/1000.0) AS ts, * FROM sqlt_data_...

    •  Update 2023-11-10:  Changed `to_timestamp(t_stamp/1000)` to `to_timestamp(t_stamp/1000.0)` in order to retain milliseconds.

    It may also be useful to note that "standard" Unix Epoch time is the number of seconds since January 1, 1970 00:00:00 UTC. The Ignition variant uses milliseconds instead of seconds and that is why all the examples start by dividing the returned t_stamp value by 1000. 

    Reference:  https://forum.inductiveautomation.com/t/understanding-tag-historian-timestamps-in-postgresql/63663 

    0

Please sign in to leave a comment.

This article has 2 comments.