Shekhar Shekhar - 2 years ago 161
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



Answer Source

well, you can use:

days(first_timestamp) * 24  + hours(first_timestamp)
     - days(second_timestamp) * 24 - hours(second_timestamp);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download