system.tag.queryTagHistory for 3 day / 3 hour segment average

hi,

I am trying to do some scripting, but I am totally out of my depth. I have a tag, [default]_25_FI_110X_Total, and I need to get the average of the last 3 days for just the first three hours of the day, 0000-0300.

I think this works for today 0000-0300 but I have no idea how to do multiple time periods to get data for all three days, if that can even be done. Do I need to do three separate functions and then average those three numbers?

here is what I have for today’s time period:

    paths = ['[default]_25_FI_110X_Total']
    startDate = system.date.midnight(system.date.now())
    endDate = system.date.addHours(startDate, 3)
    dataSet=system.tag.queryTagHistory(paths=paths, startDate=startDate, endDate=endDate, aggregationMode = 'SimpleAverage', intervalMinutes = 1, returnFormat='Wide')
    return dataSet

The historian doesn't support multiple time intervals in single calls. You will need a query per day.

1 Like

thank you