# Historical "LastValue" Script Incorrect Timestamps and Slow

**URL:** <https://forum.inductiveautomation.com/t/historical-lastvalue-script-incorrect-timestamps-and-slow/42830>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [February 1, 2021, 5:32pm UTC](https://forum.inductiveautomation.com/t/historical-lastvalue-script-incorrect-timestamps-and-slow/42830 "2021-02-01T17:32:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![benjamin.sperl](https://avatars.discourse-cdn.com/v4/letter/b/7ea924/32.png) [@benjamin.sperl](https://forum.inductiveautomation.com/u/benjamin.sperl)\
**Post date:** [February 1, 2021, 5:32pm UTC](https://forum.inductiveautomation.com/t/historical-lastvalue-script-incorrect-timestamps-and-slow/42830/1 "2021-02-01T17:32:51Z")

</div>

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:

```auto
startDateTime = system.date.addYears(selectedDateTime, -1)
dataset = system.tag.queryTagHistory(
	paths=pathList,
	startDate = startDateTime,
	endDate = selectedDateTime,
	returnSize = 1,
	aggregationMode="LastValue",
	returnFormat='Tall')

```

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
