# Logix DT datatype as DateTime gets rounded to the nearest second

**URL:** <https://forum.inductiveautomation.com/t/logix-dt-datatype-as-datetime-gets-rounded-to-the-nearest-second/75947>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [July 5, 2023, 4:05pm UTC](https://forum.inductiveautomation.com/t/logix-dt-datatype-as-datetime-gets-rounded-to-the-nearest-second/75947 "2023-07-05T16:05:30Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matt](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@Matt](https://forum.inductiveautomation.com/u/Matt)\
**Post date:** [July 5, 2023, 4:05pm UTC](https://forum.inductiveautomation.com/t/logix-dt-datatype-as-datetime-gets-rounded-to-the-nearest-second/75947/1 "2023-07-05T16:05:30Z")

</div>

I am using a transaction group to capture some timestamps in the new Logix DT datatype form a ControlLogix PLC running version 35 firmware. The data posted to the database is all rounded to the nearest second. The transaction group is configured to use the DateTime data type for these values. Is this the expected behaviour? The database shows 0 ms values for all the tags, for example: 2023-06-30 14:34:31.000.

It looks like I can switch the transaction group to Long type, which for some reason rounds off to the millisecond rather than the microseconds in the PLC. This is OK for this application, but I would prefer to stay in DateTime of there is a way to make that work.

I am running Ignition version 8.1.28.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [July 5, 2023, 4:08pm UTC](https://forum.inductiveautomation.com/t/logix-dt-datatype-as-datetime-gets-rounded-to-the-nearest-second/75947/2 "2023-07-05T16:08:40Z")

</div>

What flavor of database, and what data type is the column set to?

---

<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:** [July 5, 2023, 4:16pm UTC](https://forum.inductiveautomation.com/t/logix-dt-datatype-as-datetime-gets-rounded-to-the-nearest-second/75947/3 "2023-07-05T16:16:36Z")

</div>

Yeah, the database flavor matters for the default precision of datetime data types. PostgreSQL defaults to three decimal places but can go to six decimals. IIRC, MariaDB defaults to zero decimal places. Not sure about MS SQL Server.

---

<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:** [July 5, 2023, 4:18pm UTC](https://forum.inductiveautomation.com/t/logix-dt-datatype-as-datetime-gets-rounded-to-the-nearest-second/75947/4 "2023-07-05T16:18:28Z")

</div>

> [@Matt](#):
>
> which for some reason rounds off to the millisecond rather than the microseconds in the PLC

You might want to try [my alternate driver](https://inductiveautomation.com/moduleshowcase/module/automation-professionals-llc-ethernetip-class-1-communications). I tried hard to preserve microseconds all the way through the stack.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [July 5, 2023, 4:23pm UTC](https://forum.inductiveautomation.com/t/logix-dt-datatype-as-datetime-gets-rounded-to-the-nearest-second/75947/5 "2023-07-05T16:23:36Z")

</div>

> [@pturmel](#):
>
> Not sure about MS SQL Server.

In typical Microsoft fashion it's complicated and stupid.

Precision is milliseconds but it's rounded to .000, .003, or .007(?) seconds for DateTime

DateTime2 is better, it has a precision of 7 digits with an accuracy of 100ns.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [July 5, 2023, 4:24pm UTC](https://forum.inductiveautomation.com/t/logix-dt-datatype-as-datetime-gets-rounded-to-the-nearest-second/75947/6 "2023-07-05T16:24:49Z")

</div>

> [@pturmel](#):
>
> I tried hard to preserve microseconds all the way through the stack.

The Logix Driver preserves them all the way as well.

But neither of our drivers can overcome the fact that once it hits the Ignition tag system it becomes a Java Date, which only has millisecond precision.

---

<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:** [July 5, 2023, 4:26pm UTC](https://forum.inductiveautomation.com/t/logix-dt-datatype-as-datetime-gets-rounded-to-the-nearest-second/75947/7 "2023-07-05T16:26:34Z")

</div>

> [@Kevin.Herron](#):
>
> hits the Ignition tag system it becomes a Java Date

Ah, forgot that quirk. When I need microseconds, I'm usually using direct access in my Class 1 driver's scripting feature.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [July 5, 2023, 4:27pm UTC](https://forum.inductiveautomation.com/t/logix-dt-datatype-as-datetime-gets-rounded-to-the-nearest-second/75947/8 "2023-07-05T16:27:32Z")

</div>

Some day we should introduce a `DateTime2` tag datatype that is based on `java.time.Instant`.

---

<div class="post-metadata">

**Author:** ![Matt](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@Matt](https://forum.inductiveautomation.com/u/Matt)\
**Post date:** [July 5, 2023, 5:03pm UTC](https://forum.inductiveautomation.com/t/logix-dt-datatype-as-datetime-gets-rounded-to-the-nearest-second/75947/9 "2023-07-05T17:03:52Z")

</div>

It is a MySQL database, and the column datatype is datetime, so it should be able to support all the way down to microseconds.

Is it maybe being truncated when ignition reads it into it's own datetime type?

I appreciate all the replies here, this forum is excellent!

---

<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:** [July 5, 2023, 5:06pm UTC](https://forum.inductiveautomation.com/t/logix-dt-datatype-as-datetime-gets-rounded-to-the-nearest-second/75947/10 "2023-07-05T17:06:08Z")

</div>

> [@Matt](#):
>
> and the column datatype is datetime

That's not enough information. Is the column type `datetime(0)` or `datetime(3)` or `datetime(6)`, or something else?

---

<div class="post-metadata">

**Author:** ![Matt](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@Matt](https://forum.inductiveautomation.com/u/Matt)\
**Post date:** [July 5, 2023, 5:25pm UTC](https://forum.inductiveautomation.com/t/logix-dt-datatype-as-datetime-gets-rounded-to-the-nearest-second/75947/11 "2023-07-05T17:25:28Z")

</div>

They were datetime(0). I changed them over to datetime(6) and now I am getting my milliseconds as I would expect.

Thanks Paul!

---

<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:** [July 5, 2023, 5:26pm UTC](https://forum.inductiveautomation.com/t/logix-dt-datatype-as-datetime-gets-rounded-to-the-nearest-second/75947/12 "2023-07-05T17:26:13Z")

</div>

> [@Matt](#):
>
> Thanks Paul!

Paul?

---

<div class="post-metadata">

**Author:** ![Matt](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@Matt](https://forum.inductiveautomation.com/u/Matt)\
**Post date:** [July 5, 2023, 5:29pm UTC](https://forum.inductiveautomation.com/t/logix-dt-datatype-as-datetime-gets-rounded-to-the-nearest-second/75947/13 "2023-07-05T17:29:25Z")

</div>

For some reason my brain named you Paul, and I have no idea why? Sorry about that **¯\_(ツ)_/¯**

---

<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:** [July 5, 2023, 5:56pm UTC](https://forum.inductiveautomation.com/t/logix-dt-datatype-as-datetime-gets-rounded-to-the-nearest-second/75947/14 "2023-07-05T17:56:41Z")

</div>

It's not the first time Phil and I have been confused for each other (digitally, at least 😉)
