# Get Closest Historical Value - system.tag.queryTagHistory

**URL:** <https://forum.inductiveautomation.com/t/get-closest-historical-value-system-tag-querytaghistory/72409>\
**Category:** Ignition\
**Created:** [April 13, 2023, 2:21pm UTC](https://forum.inductiveautomation.com/t/get-closest-historical-value-system-tag-querytaghistory/72409 "2023-04-13T14:21:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![alainia.spencer](https://avatars.discourse-cdn.com/v4/letter/a/6a8cbe/32.png) [@alainia.spencer](https://forum.inductiveautomation.com/u/alainia.spencer)\
**Post date:** [April 13, 2023, 2:21pm UTC](https://forum.inductiveautomation.com/t/get-closest-historical-value-system-tag-querytaghistory/72409/1 "2023-04-13T14:21:15Z")

</div>

I'm trying to use the system.tag.queryTagHistory to get the previous day's value that is closest to 1:00.  
Based on the history for this tag, I would expect to get a value of 22,927.033, however, there is nothing being returned.

What am I missing here? Is there a better way of doing this?

Here are my parameters:

startDate= '04-12-2023 13:00:00'  
endDate= '04-12-2023 14:00:00'  
returnSize=-1  
aggregationMode='LastValue'  
noInterpolation=True

histTable = system.tag.queryTagHistory(paths=['[CoTags]OIL\_HANDLING/COCHINA\_OHF/STORAGE/STORAGE\_TANK\_COMMON/OIL\_TANKS\_TOTAL/ANALOG\_VALUE'], startDate= '04-12-2023 13:00:00',endDate= '04-12-2023 14:00:00', returnSize=-1, aggregationMode='LastValue',noInterpolation=True)

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/e/fe913d59e926555ca619313e5a48643335209ff0.png)

---

<div class="post-metadata">

**Author:** ![alainia.spencer](https://avatars.discourse-cdn.com/v4/letter/a/6a8cbe/32.png) [@alainia.spencer](https://forum.inductiveautomation.com/u/alainia.spencer)\
**Post date:** [April 18, 2023, 6:05pm UTC](https://forum.inductiveautomation.com/t/get-closest-historical-value-system-tag-querytaghistory/72409/2 "2023-04-18T18:05:16Z")

</div>

I got this working, I used the wrong start and end date formats.

It should look like the following:

2023-04-12 13:00:00
