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

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 (34.0 KB)

DailyEvac - 10-15-25 2PM.pdf (27.5 KB)

  • 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.
1 Like

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

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

What version are you using?

8.1.33

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