# \[Bug\] queryTagHistory from project script

**URL:** <https://forum.inductiveautomation.com/t/bug-querytaghistory-from-project-script/21263>\
**Category:** Ignition Early Access\
**Created:** [December 6, 2018, 4:31pm UTC](https://forum.inductiveautomation.com/t/bug-querytaghistory-from-project-script/21263 "2018-12-06T16:31:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![software.development](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/software.development/32/6688_2.png) [@software.development](https://forum.inductiveautomation.com/u/software.development)\
**Post date:** [December 6, 2018, 4:31pm UTC](https://forum.inductiveautomation.com/t/bug-querytaghistory-from-project-script/21263/1 "2018-12-06T16:31:09Z")

</div>

This function always gives None value.  
I’m basically using the script provided with Demo project source (function is queryHistory). However, if I run basic instructions from Script Console I get values (see attachments).

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/0/01b5bc1d2502e95ef28877b895c31800c22887b2.png)

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/f/fddb8b97c97b996e7d61d06dd96f522d070f6319.png)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [December 6, 2018, 5:06pm UTC](https://forum.inductiveautomation.com/t/bug-querytaghistory-from-project-script/21263/2 "2018-12-06T17:06:52Z")

</div>

Show your code. Note that many functions have additional requirements when called from a gateway script versus client/designer. Defaults for tag providers and database connections are typically unavailable, requiring explicit selection in the calls.

---

<div class="post-metadata">

**Author:** ![software.development](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/software.development/32/6688_2.png) [@software.development](https://forum.inductiveautomation.com/u/software.development)\
**Post date:** [December 7, 2018, 10:36am UTC](https://forum.inductiveautomation.com/t/bug-querytaghistory-from-project-script/21263/3 "2018-12-07T10:36:19Z")

</div>

def queryHistory(inTags, value, formatDate=False):  
ret = []

```
tagPaths = list()
tagPaths.append('S082170115122/FeedRateOverride') #with [default] is not working either

aggregationMode = None
if value.calc != None and len(value.calc):
	aggregationMode = value.calc

intervalMinutes = 1
if value.interval.units == "min":
	intervalMinutes = value.interval.duration
elif value.interval.units == "hour":
	intervalMinutes = value.interval.duration * 60
elif value.interval.units == "day":
	intervalMinutes = value.interval.duration * 60 * 24

data = None
if value.mode == "realtime":
	rangeMinutes = 5
	if value.date.mostRecent.units == "min":
		rangeMinutes = value.date.mostRecent.duration
	elif value.date.mostRecent.units == "hour":
		rangeMinutes = value.date.mostRecent.duration * 60
	elif value.date.mostRecent.units == "day":
		rangeMinutes = value.date.mostRecent.duration * 60 * 24

	data = system.tag.queryTagHistory(paths=tagPaths, rangeMinutes=rangeMinutes, intervalMinutes=intervalMinutes, aggregationMode=aggregationMode) 
elif value.mode == "historical":
	data = system.tag.queryTagHistory(paths=tagPaths, startDate=value.date.range.start, endDate=value.date.range.end, intervalMinutes=intervalMinutes, aggregationMode=aggregationMode)

if data != None:
	for i in range(data.getRowCount()):
		rowDict = {}
		
		if formatDate:
			rowDict["t_stamp"] = system.date.format(data.getValueAt(i, "t_stamp"), "yyyy-MM-dd HH:mm:ss")
		else:
			rowDict["t_stamp"] = data.getValueAt(i, "t_stamp")
			
		rowDict[tagPath[0]] = data.getValueAt(i, 1)				
		ret.append(rowDict)
		
return ret
```

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [December 7, 2018, 1:56pm UTC](https://forum.inductiveautomation.com/t/bug-querytaghistory-from-project-script/21263/4 "2018-12-07T13:56:36Z")

</div>

Your script notes that “with [defaul] is not working”. Try with the database connection name – that’s usually the name of the _history provider_.
