Tag History Hours Above X Setpoint

See the solution here, Create a report that shows how long a REAL value was above a setpoint each hour for the month - #5 by nminchin

While the post was for a report, you can run that script regardless.