# Report Script edit for month totals to year

**URL:** <https://forum.inductiveautomation.com/t/report-script-edit-for-month-totals-to-year/72739>\
**Category:** Ignition\
**Tags:** vision, ignition81, scripting\
**Created:** [April 20, 2023, 11:23pm UTC](https://forum.inductiveautomation.com/t/report-script-edit-for-month-totals-to-year/72739 "2023-04-20T23:23:24Z")\
**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:** [April 20, 2023, 11:23pm UTC](https://forum.inductiveautomation.com/t/report-script-edit-for-month-totals-to-year/72739/1 "2023-04-20T23:23:24Z")

</div>

I have a monthly report that gives me the daily totals for the month. I need to also have a report that gives me the monthly totals for the year.  
Below is my monthly script. I could use some help modifying it for monthly totals for the year.

* * *

now = system.date.now()  
lastMonth = system.date.addDays(now, -1)  
system.date.getDayOfMonth(lastMonth)

```
endTime = system.date.now()
startTime = system.date.getMonth(endTime)-1
startYear = system.date.getYear(endTime)
startDay = system.date.getDate(startYear, startTime, 1)
endDay = system.date.addDays(system.date.getDate(system.date.getYear(now),startTime + 1,1),	+0)

returnSize = system.date.daysBetween(startDay,endDay)
         tagPaths = ['[IgnitionSQL]abiop_0401_fi',
			'[IgnitionSQL]cb_09_fi',
			'[IgnitionSQL]ip_02_fi',
			'[IgnitionSQL]psp_03_fi']

```

data['MonthlyData'] = system.tag.queryTagHistory(paths=tagPaths ,returnSize = returnSize, aggregationMode='SimpleAverage', endDate=endDay, startDate=startDay)

---

<div class="post-metadata">

**Author:** ![Austin\_Dollar](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/austin_dollar/32/37052_2.png) [@Austin\_Dollar](https://forum.inductiveautomation.com/u/Austin_Dollar)\
**Post date:** [May 3, 2023, 10:27pm UTC](https://forum.inductiveautomation.com/t/report-script-edit-for-month-totals-to-year/72739/2 "2023-05-03T22:27:12Z")

</div>

Hi @user43

I simplified down your script a bit, and will include it below, using the same conventions you used in the original:

```auto
endTime = system.date.now()
startTime = system.date.getYear(endTime)-1

startYear = system.date.getYear(startTime)
startDate = system.date.getDate(startYear, 0, 1)

endYear = system.date.getYear(endTime)
endDate = system.date.getDate(endYear, 0, 1)

returnSize = system.date.monthsBetween(startDate,endDate)
         tagPaths = ['[IgnitionSQL]abiop_0401_fi',
			'[IgnitionSQL]cb_09_fi',
			'[IgnitionSQL]ip_02_fi',
			'[IgnitionSQL]psp_03_fi']
.
.
.

```

That being said, when it comes to generating a data source for a report from tag History, using a Tag history Query as your data source would be quite simpler, in that you can directly set the sample size to be a monthly interval. I'll include the link to the documentation that discusses this below:

[https://docs.inductiveautomation.com/display/DOC81/Tag+Historian+Query](https://docs.inductiveautomation.com/display/DOC81/Tag+Historian+Query)
