# Reading a value from history in a Query tag for a specific date and time

**URL:** <https://forum.inductiveautomation.com/t/reading-a-value-from-history-in-a-query-tag-for-a-specific-date-and-time/22129>\
**Category:** Ignition\
**Created:** [January 25, 2019, 7:03pm UTC](https://forum.inductiveautomation.com/t/reading-a-value-from-history-in-a-query-tag-for-a-specific-date-and-time/22129 "2019-01-25T19:03:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pdixon](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pdixon/32/6899_2.png) [@pdixon](https://forum.inductiveautomation.com/u/pdixon)\
**Post date:** [January 25, 2019, 7:03pm UTC](https://forum.inductiveautomation.com/t/reading-a-value-from-history-in-a-query-tag-for-a-specific-date-and-time/22129/1 "2019-01-25T19:03:18Z")

</div>

I am on 7.9.6 and the getHour12() and getHour24() functions are not available in that release (the tag diagnostics says it is not a recognized built-in function). I am trying to build a Query tag to retrieve a value at midnight from a previous day (the midnight() function is also not available). When I have a query like this:

SELECT TAG  
FROM TABLE  
WHERE t\_stamp \>= (cast(GETDATE( ) -1 as date))

I get a value but it may not be at midnight

It tried the following:

SELECT TAG  
FROM TABLE  
WHERE t\_stamp \>= (cast(GETDATE( ) -1 as date))  
AND getHour24(t\_stamp) = 0

but the getHour24 function is not available and I have an evaluation error

Is there a way to do this?

---

<div class="post-metadata">

**Author:** ![pdixon](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pdixon/32/6899_2.png) [@pdixon](https://forum.inductiveautomation.com/u/pdixon)\
**Post date:** [January 25, 2019, 7:29pm UTC](https://forum.inductiveautomation.com/t/reading-a-value-from-history-in-a-query-tag-for-a-specific-date-and-time/22129/2 "2019-01-25T19:29:38Z")

</div>

My error; I confused expression functions with SQL functions. The query that works is:

SELECT TAG  
FROM TABLE  
WHERE DATEPART(dy,t\_stamp) = DATEPART(dy,(cast(GETDATE( ) -1 as date)))  
AND DATEPART(hr,t\_stamp) = 0
