# How to query historical data at a certain time in Ignition

**URL:** <https://forum.inductiveautomation.com/t/how-to-query-historical-data-at-a-certain-time-in-ignition/23057>\
**Category:** Ignition\
**Tags:** python, ignition79, database\
**Created:** [March 5, 2019, 3:49am UTC](https://forum.inductiveautomation.com/t/how-to-query-historical-data-at-a-certain-time-in-ignition/23057 "2019-03-05T03:49:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lfyuntao](https://avatars.discourse-cdn.com/v4/letter/l/a5b964/32.png) [@lfyuntao](https://forum.inductiveautomation.com/u/lfyuntao)\
**Post date:** [March 5, 2019, 3:49am UTC](https://forum.inductiveautomation.com/t/how-to-query-historical-data-at-a-certain-time-in-ignition/23057/1 "2019-03-05T03:49:19Z")

</div>

My database is mysql. If I want to know the value of a tag at a specific time (e.g.2019-3-5 08:00:00), how do I do that in Ignition.

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [March 5, 2019, 3:56am UTC](https://forum.inductiveautomation.com/t/how-to-query-historical-data-at-a-certain-time-in-ignition/23057/2 "2019-03-05T03:56:13Z")

</div>

Use [system.tag.queryTagHistory](https://docs.inductiveautomation.com/display/DOC79/system.tag.queryTagHistory) to get historical tag values as stored by enabling history in tag configuration. Or [system.tag.queryTagCalculations](https://docs.inductiveautomation.com/display/DOC79/system.tag.queryTagCalculations) to get a single value.

---

<div class="post-metadata">

**Author:** ![Erin\_Wentworth](https://avatars.discourse-cdn.com/v4/letter/e/a183cd/32.png) [@Erin\_Wentworth](https://forum.inductiveautomation.com/u/Erin_Wentworth)\
**Post date:** [July 1, 2024, 6:01pm UTC](https://forum.inductiveautomation.com/t/how-to-query-historical-data-at-a-certain-time-in-ignition/23057/3 "2024-07-01T18:01:27Z")

</div>

Please help me figure this out:

I am running a queryTagHistory script to get the max value of a tag in a look-back of 30 seconds. This returns the expected max value of the tag trend, but it always returns the startDate of my query and not the timestamp of the max value. And the max value is not at the start of my window, it's near the middle.

---

<div class="post-metadata">

**Author:** ![Bushmatic](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bushmatic/32/87014_2.png) [@Bushmatic](https://forum.inductiveautomation.com/u/Bushmatic)\
**Post date:** [July 1, 2024, 7:04pm UTC](https://forum.inductiveautomation.com/t/how-to-query-historical-data-at-a-certain-time-in-ignition/23057/4 "2024-07-01T19:04:50Z")

</div>

Can you post your script (maybe in a new thread)? That function returns a dataset, so I am curious how you are getting the max value.
