-->
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.  [ 2 posts ] 
Author Message
 Post subject: sql cast as - using timestamp as a date
PostPosted: Tue Dec 09, 2003 12:17 pm 
Newbie

Joined: Tue Dec 09, 2003 12:02 pm
Posts: 1
I have an application involving booking people into shift work. The shifts have a date, start time, and end time. I store this information in two timstamps start and end. Timstamps so that I can store date and time together in one field hence easily accomodating shifts that span midnight, and leaving comaprison and time based arithemetic working correctly for reporting etc.

Some of the summary screens in the application require listing of various shifts that fall (or start on) particular days, but the time part of the start and end doesn't matter. On these screen I need to sort by start DATE (not time) and then subsort by some other field. To do this I want to:

'order by cast(shift.start as date), shift.otherfield'

Simply sorting without casting won't work as the subsort will be by time rather than the other field. Can I do this sql casting with hibernate? Would I need to drop down to a sql query?

many thanks
markj


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 09, 2003 7:47 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
you can call SQL functions in the HQL order by clause


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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.