# I’ve been trying to create a report that uses a historical query data source but I just can't get what I want

**URL:** <https://forum.inductiveautomation.com/t/i-ve-been-trying-to-create-a-report-that-uses-a-historical-query-data-source-but-i-just-cant-get-what-i-want/111487>\
**Category:** Ignition\
**Created:** [October 15, 2025, 8:07pm UTC](https://forum.inductiveautomation.com/t/i-ve-been-trying-to-create-a-report-that-uses-a-historical-query-data-source-but-i-just-cant-get-what-i-want/111487 "2025-10-15T20:07:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gaven\_Trevino](https://avatars.discourse-cdn.com/v4/letter/g/58f4c7/32.png) [@Gaven\_Trevino](https://forum.inductiveautomation.com/u/Gaven_Trevino)\
**Post date:** [October 15, 2025, 8:07pm UTC](https://forum.inductiveautomation.com/t/i-ve-been-trying-to-create-a-report-that-uses-a-historical-query-data-source-but-i-just-cant-get-what-i-want/111487/1 "2025-10-15T20:07:03Z")

</div>

I’ve been trying to create a report that uses a historical query data source. I have it set up the way I want, with my start time defined as:  
`dateArithmetic(toDate(dateFormat(now(), "yyyy-MM-dd 6:55:00")), 0, "day")`  
and my end time as:  
`dateArithmetic(toDate(dateFormat(now(), "yyyy-MM-dd 14:05:00")), 0, "day")`.

My server is in Central Time, while I’m in Eastern Time, as are my PLC machines. I set those start and end times so the report would cover data from **7:55 AM to 2:59 PM Eastern** , capturing one data point at the end of each hour.

The issue I’m having is that the query always returns **extra data** , adding a **row 0**. For example, there should only be eight rows (one for each hour), but for some reason, there are always rows 0–8, resulting in an extra one. Additionally, the hour from **2:00–2:59 PM** is always blank. I run the report at **3:10 PM Eastern**.

Can anyone help me figure out why this is happening? Below is the imagine of the report I get for all machines and the data it says its pulling for this certain report.

[evac data.pdf](https://forum.inductiveautomation.com/uploads/short-url/hOeAWTLSMBpMSQcoqCEmMxKIT7n.pdf) (34.0 KB)

[DailyEvac - 10-15-25 2PM.pdf](https://forum.inductiveautomation.com/uploads/short-url/pFFGffY6tszCWCgm3a76Tn18LGb.pdf) (27.5 KB)

---

<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:** [October 15, 2025, 8:22pm UTC](https://forum.inductiveautomation.com/t/i-ve-been-trying-to-create-a-report-that-uses-a-historical-query-data-source-but-i-just-cant-get-what-i-want/111487/2 "2025-10-15T20:22:29Z")

</div>

- Do not use string formatting and string parsing to manipulate datetime values. They are ambiguous when time zones or DST is involved. Use date arithmetic explicitly. If you need behavior that doesn't match the timezone of the gateway, then you will need to explicitly use java's `ZonedDateTime` class to do your arithmetic.
- History queries that are intended to delivery hourly values must have start and end times that are precisely multiples of hours apart, less one millisecond. (Early API decision to not use half-open intervals that we are stuck with.)
- Use aggregation mode to pick first or last values within your intervals.

---

<div class="post-metadata">

**Author:** ![Gaven\_Trevino](https://avatars.discourse-cdn.com/v4/letter/g/58f4c7/32.png) [@Gaven\_Trevino](https://forum.inductiveautomation.com/u/Gaven_Trevino)\
**Post date:** [October 16, 2025, 12:45pm UTC](https://forum.inductiveautomation.com/t/i-ve-been-trying-to-create-a-report-that-uses-a-historical-query-data-source-but-i-just-cant-get-what-i-want/111487/3 "2025-10-16T12:45:12Z")

</div>

> [@pturmel](#):
>
> Use aggregation mode to pick first or last values within you

Thank you! What if first and last don’t show in the aggregation mode drop down.

---

<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:** [October 16, 2025, 12:56pm UTC](https://forum.inductiveautomation.com/t/i-ve-been-trying-to-create-a-report-that-uses-a-historical-query-data-source-but-i-just-cant-get-what-i-want/111487/4 "2025-10-16T12:56:32Z")

</div>

Hmm. I misremembered. "LastValue" should be an option, but there's no "first" aggregation mode.

What version are you using?

---

<div class="post-metadata">

**Author:** ![Gaven\_Trevino](https://avatars.discourse-cdn.com/v4/letter/g/58f4c7/32.png) [@Gaven\_Trevino](https://forum.inductiveautomation.com/u/Gaven_Trevino)\
**Post date:** [October 16, 2025, 12:57pm UTC](https://forum.inductiveautomation.com/t/i-ve-been-trying-to-create-a-report-that-uses-a-historical-query-data-source-but-i-just-cant-get-what-i-want/111487/5 "2025-10-16T12:57:43Z")

</div>

**8.1.33**

---

<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:** [October 16, 2025, 1:03pm UTC](https://forum.inductiveautomation.com/t/i-ve-been-trying-to-create-a-report-that-uses-a-historical-query-data-source-but-i-just-cant-get-what-i-want/111487/6 "2025-10-16T13:03:57Z")

</div>

Consider using `system.tag.queryTagHistory()` in a data script to use options not exposed in the history binding UI.
