Query Tag History - out of bounds

I have a tag "Pressure" im logging every second through the historian properties to a microsoft SQL database. I need to pull the value of that tag from X minutes ago in order to calculate the difference between X minutes ago and the value now.

The plan was to have seperate tags that would show this info easily.

i was trying to use querytaghistory() but im getting an out of bounds error.. is there any easier way to do this?

Is what i have scripted wrong

endTime = system.date.now()
value = system.tag.readBlocking('[default]Test Information/test parameters/Hold Period.value')[0].value
startTime = system.date.addMinutes(endTime, -value)
dataSet = system.tag.queryTagHistory(paths=('[default]Test/Pressure'), startDate=startTime, endDate=endTime,returnSize=1)

Are the history properties set up correctly also?

image

bump

IMO, it would be easier to use a transaction group or script to achieve similar result (if you don't have TG license), store to a tall table and use SQL to calculate the delta.

how do i pull specific values from timestamp points i want from the transaction group?