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

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?

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

1 Like