# Query Tag History - out of bounds

**URL:** <https://forum.inductiveautomation.com/t/query-tag-history-out-of-bounds/82660>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [December 4, 2023, 3:35pm UTC](https://forum.inductiveautomation.com/t/query-tag-history-out-of-bounds/82660 "2023-12-04T15:35:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Why\_Me](https://avatars.discourse-cdn.com/v4/letter/w/b4bc9f/32.png) [@Why\_Me](https://forum.inductiveautomation.com/u/Why_Me)\
**Post date:** [December 4, 2023, 3:35pm UTC](https://forum.inductiveautomation.com/t/query-tag-history-out-of-bounds/82660/1 "2023-12-04T15:35:40Z")

</div>

I have a tag "Pressure" im logging every second through the historian properties to a microsoft SQL database. I need to pull the value of that tag from X minutes ago in order to calculate the difference between X minutes ago and the value now.

The plan was to have seperate tags that would show this info easily.

i was trying to use querytaghistory() but im getting an out of bounds error.. is there any easier way to do this?

Is what i have scripted wrong

```auto
endTime = system.date.now()
value = system.tag.readBlocking('[default]Test Information/test parameters/Hold Period.value')[0].value
startTime = system.date.addMinutes(endTime, -value)
dataSet = system.tag.queryTagHistory(paths=('[default]Test/Pressure'), startDate=startTime, endDate=endTime,returnSize=1)

```

Are the history properties set up correctly also?

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

---

<div class="post-metadata">

**Author:** ![Why\_Me](https://avatars.discourse-cdn.com/v4/letter/w/b4bc9f/32.png) [@Why\_Me](https://forum.inductiveautomation.com/u/Why_Me)\
**Post date:** [December 4, 2023, 6:07pm UTC](https://forum.inductiveautomation.com/t/query-tag-history-out-of-bounds/82660/2 "2023-12-04T18:07:39Z")

</div>

bump

---

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [December 4, 2023, 6:28pm UTC](https://forum.inductiveautomation.com/t/query-tag-history-out-of-bounds/82660/3 "2023-12-04T18:28:50Z")

</div>

> [@Why\_Me](#):
>
> is there any easier way to do this?

IMO, it would be easier to use a transaction group or script to achieve similar result (if you don't have TG license), store to a tall table and use SQL to calculate the delta.

---

<div class="post-metadata">

**Author:** ![Why\_Me](https://avatars.discourse-cdn.com/v4/letter/w/b4bc9f/32.png) [@Why\_Me](https://forum.inductiveautomation.com/u/Why_Me)\
**Post date:** [December 4, 2023, 6:42pm UTC](https://forum.inductiveautomation.com/t/query-tag-history-out-of-bounds/82660/4 "2023-12-04T18:42:52Z")

</div>

how do i pull specific values from timestamp points i want from the transaction group?

---

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [December 4, 2023, 10:53pm UTC](https://forum.inductiveautomation.com/t/query-tag-history-out-of-bounds/82660/5 "2023-12-04T22:53:00Z")

</div>

> [@Matrix\_Engineering](#):
>
> use SQL to calculate the delta

> **[SQL Tutorial](https://www.w3schools.com/sql/)**
>
> W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.
