# Querying: Diff between historical path of a tag and regular tag path

**URL:** <https://forum.inductiveautomation.com/t/querying-diff-between-historical-path-of-a-tag-and-regular-tag-path/100058>\
**Category:** Ignition\
**Created:** [December 19, 2024, 6:48pm UTC](https://forum.inductiveautomation.com/t/querying-diff-between-historical-path-of-a-tag-and-regular-tag-path/100058 "2024-12-19T18:48:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Asjal\_Ahmad](https://avatars.discourse-cdn.com/v4/letter/a/9e8a1a/32.png) [@Asjal\_Ahmad](https://forum.inductiveautomation.com/u/Asjal_Ahmad)\
**Post date:** [December 19, 2024, 6:48pm UTC](https://forum.inductiveautomation.com/t/querying-diff-between-historical-path-of-a-tag-and-regular-tag-path/100058/1 "2024-12-19T18:48:39Z")

</div>

I'm using [system.tag.queryTagHistory | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-tag/system-tag-queryTagHistory) to query tag history. What is the difference between using a historical path of a tag and a regular tag path for this function?  
An example of a historical tag path is the return result of this function [system.tag.browseHistoricalTags | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-tag/system-tag-browseHistoricalTags) like `histprov:historian_db:/drv:gateway_provider:/tag:tmp` and a regular path `[default]tmp`.

Both seem to work, but sometimes there are small discrepancies in the values.

---

<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:** [December 19, 2024, 6:56pm UTC](https://forum.inductiveautomation.com/t/querying-diff-between-historical-path-of-a-tag-and-regular-tag-path/100058/2 "2024-12-19T18:56:55Z")

</div>

> [@Asjal\_Ahmad](#):
>
> Both seem to work

They should. When using just a tag provider name, the system function asks that tag provider to do the actual query, which then constructs the full historian path from the tag properties on the spot.

> [@Asjal\_Ahmad](#):
>
> small discrepancies in the values.

Please elaborate. (Most small discrepancies are caused interpolation side effects when using imprecise time endpoints.)

---

<div class="post-metadata">

**Author:** ![Asjal\_Ahmad](https://avatars.discourse-cdn.com/v4/letter/a/9e8a1a/32.png) [@Asjal\_Ahmad](https://forum.inductiveautomation.com/u/Asjal_Ahmad)\
**Post date:** [December 19, 2024, 7:18pm UTC](https://forum.inductiveautomation.com/t/querying-diff-between-historical-path-of-a-tag-and-regular-tag-path/100058/3 "2024-12-19T19:18:13Z")

</div>

I think you're correct. I was using `endDate` as now which was causing a discrepancy in the last (most recent) value, especially when I used `aggregationMode='LastValue'`. Once I started using past times, the values are the same.

Interestingly, if I use `aggregationMode='LastValue'` and `endDate` as `system.date.now()`. Some values come in as 0 for the historical tag path but an actual value for the regular tag path.

Here's some test code

```python
def pretty_print_dataset(dataset):
    .
    .
    .

endTime = system.date.now()
startTime = system.date.addMinutes(endTime, -10)
dataSet = system.tag.queryTagHistory(
    paths=[...],
    intervalMinutes=1,
    startDate=startTime,
    endDate=endTime,
    aggregationMode="LastValue",
    returnFormat='Wide',
    columnNames=['historical', 'regular'],
    noInterpolation=True,
    includeBoundingValues=False,
)

pretty_print_dataset(dataSet)

```

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

---

<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:** [December 19, 2024, 7:22pm UTC](https://forum.inductiveautomation.com/t/querying-diff-between-historical-path-of-a-tag-and-regular-tag-path/100058/4 "2024-12-19T19:22:19Z")

</div>

I recommend you never directly use the value from the `now()` expression function or the `system.date.now()` scripting function in your history query. Those functions return milli-second precision timestamps, and therefore shift the time period of the query away from the "natural" start and end timestamps people think they are going to get.

Timestamps should always be truncated to zero milliseconds, or zero seconds, or zero minutes, or whatever boundary makes sense for your data, before it is handed to a history query.
