# system.tag.queryTagHistory / aggregationMode='Interpolation v7.9

**URL:** <https://forum.inductiveautomation.com/t/system-tag-querytaghistory-aggregationmode-interpolation-v7-9/101057>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [January 17, 2025, 8:43pm UTC](https://forum.inductiveautomation.com/t/system-tag-querytaghistory-aggregationmode-interpolation-v7-9/101057 "2025-01-17T20:43:36Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yidir](https://avatars.discourse-cdn.com/v4/letter/y/35a633/32.png) [@yidir](https://forum.inductiveautomation.com/u/yidir)\
**Post date:** [January 17, 2025, 8:43pm UTC](https://forum.inductiveautomation.com/t/system-tag-querytaghistory-aggregationmode-interpolation-v7-9/101057/1 "2025-01-17T20:43:36Z")

</div>

I'm trying to query tags for a 24h period on 1-second intervals (expecting 86400 points).  
I'm working on Vision 7.9.  
This same code works on 8.1.  
i'm getting ~34000 data points (but that must be related to how i configured my historian). 7.9 looks like it can't do the interpolation like 8.1?

```python
try:
    dataSet = system.tag.queryTagHistory(
        paths=tag_path,
        startDate=startTime,
        endDate=endTime,
        intervalSeconds=interval_seconds, # Interpolated to 1-second intervals
        returnFormat='Wide',
        aggregationMode='Interpolation' # Fill in missing data points
    )
    pyData = system.dataset.toPyDataSet(dataSet)
except:
    system.gui.errorBox("Error querying tag history. Please check your tag paths or date range.")
    pyData = None # Set pyData to None to handle errors later

```

---

<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:** [January 17, 2025, 10:22pm UTC](https://forum.inductiveautomation.com/t/system-tag-querytaghistory-aggregationmode-interpolation-v7-9/101057/2 "2025-01-17T22:22:54Z")

</div>

> [@yidir](#):
>
> `aggregationMode='Interpolation'`

This is not how you turn on interpolation, and it is not a valid aggregate, the code just ignores it (well actually it tries/and fails to execute it as a custom python aggregation but I'm not sure if that is logged or it just fails silently.)

If it did throw an error, and it may, your except block would not catch it as it would be a Java Exception and not a Python Exception. You need to import `java.lang.Throwable` and add a catch for that to catch any Java Errors.

```python
    dataSet = system.tag.queryTagHistory(
        paths=tag_path,
        startDate = startTime,
        endDate = endTime,
        intervalSeconds = interval_seconds,
        returnFormat = 'Wide',
        noInterpolation = False
    )
    pyData = system.dataset.toPyDataSet(dataSet)

```

I have ommitted the exception handling from the sample script. For proper error handling in Ignition you should follow the advice given here:

> [@Using Java.net Socket](https://forum.inductiveautomation.com/t/using-java-net-socket/79962/21):
>
> That won't catch everything. And it mixes data types for e. I use (and strongly recommend) this construct (shown as if a library script): from java.lang import Throwable logger = system.util.getLogger(system.util.getProjectName() + '.' + \_\_name\_\_) def someTask(): try: someaction() except Throwable, t: # Throwable is the ultimate superclass of all java exceptions and errors logger.warn("some text for java", t) except Exception, e # Exception is python's superclass (technically Bas…

---

<div class="post-metadata">

**Author:** ![yidir](https://avatars.discourse-cdn.com/v4/letter/y/35a633/32.png) [@yidir](https://forum.inductiveautomation.com/u/yidir)\
**Post date:** [January 19, 2025, 7:01pm UTC](https://forum.inductiveautomation.com/t/system-tag-querytaghistory-aggregationmode-interpolation-v7-9/101057/3 "2025-01-19T19:01:19Z")

</div>

the `noInterpolation = False` has no effect - It still outputs the raw number of points. I did a one-hour range test where interval\_seconds = 1. Instead of getting 3600 points, I'm only getting the raw points. no interpolation was made. I tested with IntervalMinutes and it worked. it looks like IntervalsSeconds is not available for 7.9 [system.tag.queryTagHistory | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/7.9/appendix/scripting-functions/system-tag/system-tag-queryTagHistory)

---

<div class="post-metadata">

**Author:** ![yidir](https://avatars.discourse-cdn.com/v4/letter/y/35a633/32.png) [@yidir](https://forum.inductiveautomation.com/u/yidir)\
**Post date:** [January 19, 2025, 7:17pm UTC](https://forum.inductiveautomation.com/t/system-tag-querytaghistory-aggregationmode-interpolation-v7-9/101057/4 "2025-01-19T19:17:55Z")

</div>

the solution is to use `returnSize` dynamically as a difference of endtime and starttime (multiplied by any factor if we want)
