dawuad wrote:
I would like to calculate how long an employee has worked. I currently have MySQL and I am unable to use timediff() function of mysql to calculate the difference between logintime and logoutime. Could someone tell me what HQL I would need. The following is in native SQL:
select timediff(el.logintime, el.logouttime) from EmployeeLogon el where el.EmployeeID = 31
When I try to execute in Hibernate, I get an error stating that the 'timediff' is in an invalid alias. Could someone tell me how I may calculate time.
Please note that the fields logintime and logouttime is of type DateTime
You can always use a SQLQuery and bypass using HQL for this.