[feature-9009]system.tag.queryTagHistory() - Interval less than 1 minute

I have been using the system.tag.queryTagHistory() function for a little while now.
Generally I have used it on the ‘Ignition’ Tag Historian data to return tag history interpolated at a minimum interval of 1 minute or at the scan rate of the specified tag path/s.

I now have a requirement to return interpolated historical data from an OPC-HDA server at intervals less than 1 minute, in this case, 15 seconds.

I know Ignition can retrieve and interpolate historical data from the OPC-HDA server at a 15 second interval because I was able to do so with the tag history binding on a table and chart in Vision and Perspective. However, when i use the system,util.queryTagHistory() function, it will only give me a minimum interval of 1 minute (Example script below).

args = {
			'paths':['[OPC-HDA]Some Tag'],
result = system.tag.queryTagHistory(**args)

Is it possible to return interpolated historical data with an interval less than 1 minute using the system,util.queryTagHistory, if so, then how?

If you set your ‘returnSize’ based on your range and interval it should give you want you want. Where you are looking at a 5 minute range. set it to 20 instead of -1. -1 will return values on change. Setting it to 20 you will get 20 results evenly space so a 15 second interval over 5 minutes.

There’s a longstanding ticket to add intervalSeconds/rangeSeconds to the queryTagHistory function that I’ve added you to. We’re also planning to introduce a few new, simplified functions for specific types of history queries - they’ll still be doing the same thing as queryTagHistory, but specifically designed for, say, retrieving the value at a particular timestamp without having to specify all the arguments manually.

Here is the code @bpreston talked about, if you want to specify the sample time in seconds:

def getHistoryDataset(PATHS,startDate,endDate,intervalSeconds,returnSize,aggregationMode,timeout):
	endTime = endDate
	startTime = startDate
	# Query historian 
	secondsBetween = system.date.secondsBetween(startTime,endTime)
	returnSize = secondsBetween/intervalSeconds+intervalSeconds
	dataSet = system.tag.queryTagHistory(paths=PATHS, startDate=startTime, endDate=endTime, returnSize=returnSize, aggregationMode=aggregationMODE, returnFormat='Wide',timeout=timeout)

Thanks all, I appreciate all the responses and have been able to make it work in my case.