Report Script edit for month totals to year

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)

Hi @user43

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

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