Shekhar Shekhar - 1 month ago 7
Java Question

how to find difference between two timestamp using hibernate query language

I am trying to write an hql query which gives me the number of hours between two timestamp.

So, far i am unable to do this. I have used hql hour function but that does not work if the

timestamp corresponds to different date. Please provide any input.

My hql query is

select count(*) from as request where = :id and hour(current_timestamp - request.lastEventDate) > :delay




well, you can use:

days(first_timestamp) * 24  + hours(first_timestamp)
     - days(second_timestamp) * 24 - hours(second_timestamp);