Report Script - end time

I have a report script that runs the report at 6 AM and ends at 5 AM. It should be Start at 6 AM and end at 5:59 AM. How would I change the script to catch the last 59 min. that I'm missing?

Thanks.

Blockquote

endTime = system.date.now()
startTime = system.date.addHours(endTime,-24)
tagPaths = ['[IgnitionSQL]abiop_0401_fi',
'[IgnitionSQL]cbiop_1701_li',
'[IgnitionSQL]cbiop_1702_li',
'[IgnitionSQL]cbiop_1703_li',

data['tagData'] = system.tag.queryTagHistory(paths=tagPaths , returnSize = 24, aggregationMode='SimpleAverage', endDate=endTime, startDate=startTime)

Your return size is 24, and you are covering 24 hours, so the data will start with your start date and return 24 evenly spaced data points. The last data point will end up being 1 hour before datetime now. If you need a data point for every minute, you will need to increase your return size to 1440 to cover the full 24 hour period.
This would be the code:
data['tagData'] = system.tag.queryTagHistory(paths=tagPaths , returnSize = 1440, aggregationMode='SimpleAverage', endDate=endTime, startDate=startTime)

If you simply want 24 data points with the last data point being precisely 1 minute before date.now() you could offset your endTime by 59 minutes and still use your original query:

endTime = system.date.addMinutes(system.date.now(), 59)
startTime = system.date.addHours(endTime,-24)
tagPaths = ['[IgnitionSQL]abiop_0401_fi',
'[IgnitionSQL]cbiop_1701_li',
'[IgnitionSQL]cbiop_1702_li',
'[IgnitionSQL]cbiop_1703_li']
data['tagData'] = system.tag.queryTagHistory(paths=tagPaths , returnSize = 24, aggregationMode='SimpleAverage', endDate=endTime, startDate=startTime)
1 Like