How to get Date Difference in hour using HQL How to get Date Difference in hour using HQL postgresql postgresql

How to get Date Difference in hour using HQL


  1. HQL supports EXTRACT(... FROM ...) function, and EPOCH keyword although it is not mentioned in documentstion.
  2. HQL also supports no-argument LOCALTIMESTAMP function (for Postgres and MySQL dialects). This fact also is not in documentation, but I found it in sources (link1, link2)

So, required HQL query is:

FROM SomeEntity p WHERE EXTRACT(EPOCH FROM (LOCALTIMESTAMP-p.storageTime))/3600 > :threshold