# queryTagHistory and DST

**URL:** <https://forum.inductiveautomation.com/t/querytaghistory-and-dst/88952>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [April 17, 2024, 12:02am UTC](https://forum.inductiveautomation.com/t/querytaghistory-and-dst/88952 "2024-04-17T00:02:42Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shawn\_Rieger1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/shawn_rieger1/32/57040_2.png) [@Shawn\_Rieger1](https://forum.inductiveautomation.com/u/Shawn_Rieger1)\
**Post date:** [April 17, 2024, 12:02am UTC](https://forum.inductiveautomation.com/t/querytaghistory-and-dst/88952/1 "2024-04-17T00:02:43Z")

</div>

How does Ignition handle requesting data via queryTagHistory that spans a transition into or out of daylight savings time? I'm not seeing one hour less into DST and an extra hour out of DST, as I would expect.

---

<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:** [April 17, 2024, 12:30am UTC](https://forum.inductiveautomation.com/t/querytaghistory-and-dst/88952/2 "2024-04-17T00:30:50Z")

</div>

Ignition datetime values are really instances of `java.util.Date`, which are UTC under the hood. Always. They display in a local time zone when printed (stringified), and are constructed in local time zones when parsed. At all other times, they are zone-less. You should recheck how you are generating your start/end boundaries.

---

<div class="post-metadata">

**Author:** ![Shawn\_Rieger1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/shawn_rieger1/32/57040_2.png) [@Shawn\_Rieger1](https://forum.inductiveautomation.com/u/Shawn_Rieger1)\
**Post date:** [April 17, 2024, 12:43am UTC](https://forum.inductiveautomation.com/t/querytaghistory-and-dst/88952/3 "2024-04-17T00:43:00Z")

</div>

I'm specifying startDate and endDate with Ignition DateTime objects.

---

<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:** [April 17, 2024, 11:42am UTC](https://forum.inductiveautomation.com/t/querytaghistory-and-dst/88952/4 "2024-04-17T11:42:34Z")

</div>

Of course you are, because that's what the function requires. How are you getting those Datetime objects? Show your code.

---

<div class="post-metadata">

**Author:** ![Shawn\_Rieger1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/shawn_rieger1/32/57040_2.png) [@Shawn\_Rieger1](https://forum.inductiveautomation.com/u/Shawn_Rieger1)\
**Post date:** [April 17, 2024, 1:58pm UTC](https://forum.inductiveautomation.com/t/querytaghistory-and-dst/88952/5 "2024-04-17T13:58:30Z")

</div>

```auto
# ./Controls/Start & ./Controls/End = Perspective DateTime Inputs

# props.custom.start (expr) = 
# if({this.custom.historical}, {./Controls/Start.props.value}, addMinutes({this.custom.end}, {this.custom.minutes}*-1))

props = self.custom
props.wait = True
query_tags = []

for tag in props.tags:
    query_tags.append(str(tag.path))

data = system.tag.queryTagHistory(
    paths = query_tags,
    startDate = props.start,
    endDate = props.end,
    columnNames = query_tags,
    returnSize = props.returnSize,
    intervalSeconds = props.aggregation,
    aggregationMode = props.aggregationMode,
    noInterpolation = False,
    ignoreBadQuality = True,
    validateSCExec = False)

self.refreshLayout()

props.data = data
props.wait = False

```

---

<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:** [April 17, 2024, 2:03pm UTC](https://forum.inductiveautomation.com/t/querytaghistory-and-dst/88952/6 "2024-04-17T14:03:16Z")

</div>

Ok, you have custom datetime properties. How are you writing to those before the history query runs?

Some other script? Datetime input components?

---

<div class="post-metadata">

**Author:** ![Shawn\_Rieger1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/shawn_rieger1/32/57040_2.png) [@Shawn\_Rieger1](https://forum.inductiveautomation.com/u/Shawn_Rieger1)\
**Post date:** [April 17, 2024, 2:23pm UTC](https://forum.inductiveautomation.com/t/querytaghistory-and-dst/88952/7 "2024-04-17T14:23:13Z")

</div>

Yes. See the top comment in the above code for reference. I'm using DateTime Input components. The value is being read from a custom property via expression. Depending on the mode, I'm either taking the value directly or using the end time and deducting a specified number of minutes using the addMinutes expression function.

---

<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:** [April 17, 2024, 2:39pm UTC](https://forum.inductiveautomation.com/t/querytaghistory-and-dst/88952/8 "2024-04-17T14:39:33Z")

</div>

What does your session timezone property show? (That is what your datetime inputs will use.) The date arithmetic for non-historical will act on the UTC datetime objects, so I hope you don't expect **that** to respect your time zones.

---

<div class="post-metadata">

**Author:** ![Shawn\_Rieger1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/shawn_rieger1/32/57040_2.png) [@Shawn\_Rieger1](https://forum.inductiveautomation.com/u/Shawn_Rieger1)\
**Post date:** [April 17, 2024, 4:54pm UTC](https://forum.inductiveautomation.com/t/querytaghistory-and-dst/88952/9 "2024-04-17T16:54:45Z")

</div>

That's It. It does seem the perspective project was changed to UTC at some point. I understand now, thank you. I should have checked there first. When the zone is set correctly, it does, in fact, return the extra hour when transitioning from PDT to PST.
