# Report Script - end time

**URL:** <https://forum.inductiveautomation.com/t/report-script-end-time/65364>\
**Category:** Ignition\
**Tags:** ignition81, vision, scripting\
**Created:** [October 18, 2022, 8:02pm UTC](https://forum.inductiveautomation.com/t/report-script-end-time/65364 "2022-10-18T20:02:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![user43](https://avatars.discourse-cdn.com/v4/letter/u/8dc957/32.png) [@user43](https://forum.inductiveautomation.com/u/user43)\
**Post date:** [October 18, 2022, 8:02pm UTC](https://forum.inductiveautomation.com/t/report-script-end-time/65364/1 "2022-10-18T20:02:46Z")

</div>

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)

```

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [October 19, 2022, 2:43am UTC](https://forum.inductiveautomation.com/t/report-script-end-time/65364/2 "2022-10-19T02:43:43Z")

</div>

> [@user43](#):
>
> `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:

```auto
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)

```
