views:

293

answers:

1

Hello

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 com.xxx.Request as request where request.id = :id and hour(current_timestamp - request.lastEventDate) > :delay

Thanks

Shekhar

+3  A: 

well, you can use:

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