Historical "LastValue" Script Incorrect Timestamps and Slow

Hello all,

I’m having issues with the function “system.tag.queryTagHistory”. The intention of the script is to see the values of a group a tags at any given moment. So I am using the “Last Value” aggregation with a returnSize of 1.

My script is below:

startDateTime = system.date.addYears(selectedDateTime, -1)
dataset = system.tag.queryTagHistory(
	startDate = startDateTime,
	endDate = selectedDateTime,
	returnSize = 1,

The script is returning the correct values. But the timestamp is always the startDate even though I manually changed the values just minutes before running the script and it is correctly getting those values.

Also, if I have any more that two tags in the “pathList”, the query takes ~40 seconds. It returns the same results. With one or two tags in the pathList array, the value is returned is milliseconds