# queryTagHistory Getting Wrong Values

**URL:** <https://forum.inductiveautomation.com/t/querytaghistory-getting-wrong-values/69443>\
**Category:** Ignition\
**Tags:** ignition79, vision\
**Created:** [February 3, 2023, 11:49pm UTC](https://forum.inductiveautomation.com/t/querytaghistory-getting-wrong-values/69443 "2023-02-03T23:49:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dan\_Mor](https://avatars.discourse-cdn.com/v4/letter/d/9dc877/32.png) [@Dan\_Mor](https://forum.inductiveautomation.com/u/Dan_Mor)\
**Post date:** [February 3, 2023, 11:49pm UTC](https://forum.inductiveautomation.com/t/querytaghistory-getting-wrong-values/69443/1 "2023-02-03T23:49:59Z")

</div>

Hi, I'm trying to get a dataset with values from a historical tag using queryTagHistory(). The concept is that once the user selected the two dates (range), and then click on "Get Data", the data will be displayed on the table. The problem is that the values on the "first shift efficiency" column are wrong. In the example bellow you can see that the value at 1/28/2023 1:00pm should be 40.44 but the dataset has 47.66 instead.

**Comparing values with chart.**

 ![Untitled](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/4/e49f73743f807171ccca5c5130fcbad705b74a2e.png)

**Script in the button.**

 ![Untitled](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/0/209d019d67295ef9659a8a63f7fede2babec9c6e.png)

**Tag history settings:**

 ![Capture](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/c/9ca3c2975abbf7dfb55d1ecc0f619c08f91c1ede.png)

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [February 4, 2023, 4:41am UTC](https://forum.inductiveautomation.com/t/querytaghistory-getting-wrong-values/69443/2 "2023-02-04T04:41:17Z")

</div>

Are the values misaligned? I've seen similar posts in the forum before.

> [@\[Bug?\]: system.tag.queryTagHistory data issue](https://forum.inductiveautomation.com/t/bug-system-tag-querytaghistory-data-issue/64872/2):
>
> I was able to reproduce your result using power tables, and it really does seem like a bug. When I use system.tag.queryTagHistory with a returnSize parameter of anything other than the default -1, my resultant columns are misaligned by 1 value: In the above example, the table on the left has a return size of 10, and the table on the right has the default return size. Query 1 code: system.tag.queryTagHistory(paths=[path1], startDate=startTime, endDate=endTime, returnSize=10, aggregat…

---

<div class="post-metadata">

**Author:** ![Dan\_Mor](https://avatars.discourse-cdn.com/v4/letter/d/9dc877/32.png) [@Dan\_Mor](https://forum.inductiveautomation.com/u/Dan_Mor)\
**Post date:** [February 5, 2023, 12:24am UTC](https://forum.inductiveautomation.com/t/querytaghistory-getting-wrong-values/69443/3 "2023-02-05T00:24:17Z")

</div>

Correct, the values are misaligned by one. A bug?

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [February 5, 2023, 1:02am UTC](https://forum.inductiveautomation.com/t/querytaghistory-getting-wrong-values/69443/4 "2023-02-05T01:02:01Z")

</div>

Seems to be. When I first encountered somebody talking about this in the forum, I set up an experiment, and I found that I was able to independently replicate the problem. I'm not sure if anybody got around to reporting it or if IA has any kind of ticket open on this problem, but since nobody has responded as such, the proper course of action would be to get [official support](https://support.inductiveautomation.com/) involved, and it would be great if you could report back what you find out from them for future reference in the forum.

---

<div class="post-metadata">

**Author:** ![tebright1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tebright1/32/87405_2.png) [@tebright1](https://forum.inductiveautomation.com/u/tebright1)\
**Post date:** [May 15, 2024, 7:47pm UTC](https://forum.inductiveautomation.com/t/querytaghistory-getting-wrong-values/69443/5 "2024-05-15T19:47:48Z")

</div>

I had an issue in my perspective app where the time was including milliseconds and causing my table to show different values every time I loaded it.

So I was setting the start and stop times with 0 for the minutes. I found that I had 3 values at the minute time with 3 different values. because of millisecond points. Not sure this is your issue, but zeroing out the milliseconds value help fix my issue.

**Date entry:**

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

**Strip millis:**

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

**Update db dates:**

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

**Shows full date/time with ms at 0:**  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/f/5f304b9ee55b3ac9d3d9f17aa13f45e0e25fffbd.png)

---

<div class="post-metadata">

**Author:** ![Dan\_Mor](https://avatars.discourse-cdn.com/v4/letter/d/9dc877/32.png) [@Dan\_Mor](https://forum.inductiveautomation.com/u/Dan_Mor)\
**Post date:** [October 1, 2025, 5:17pm UTC](https://forum.inductiveautomation.com/t/querytaghistory-getting-wrong-values/69443/6 "2025-10-01T17:17:49Z")

</div>

Will try it out, thanks
