-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: HQL Calculate hours worked
PostPosted: Fri Jul 29, 2005 4:55 pm 
Regular
Regular

Joined: Wed Sep 29, 2004 11:34 am
Posts: 62
Location: Houston, TX
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


Top
 Profile  
 
 Post subject: Re: HQL Calculate hours worked
PostPosted: Fri Jul 29, 2005 5:13 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
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.

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 29, 2005 5:50 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Create a custom dialect and register datediff and timediff as SQL functions.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.