-->
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: Problem while sorting datetime field based on date alone
PostPosted: Thu Jul 22, 2010 3:02 am 
Newbie

Joined: Thu Jul 22, 2010 2:39 am
Posts: 3
I have a date object in the bean class called "dateTime" which
contains both date and time.
When I list the records of that bean class I am saying

criteria.addOrder(Order.desc("dateTime"));

This will sort based on date as well as the time. But I want the sorting only based on date not by time.
Is there a way to do this in hibernate?

I am using PostgreSQL as well as SqlServer database.
In postgreSQL,

criteria.addOrder(Order.desc("dateTime")); is equivalent to the SQL query "... ORDER BY dateTime desc;"

if I change my SQL query to "... ORDER BY to_char(dateTime, 'MM-DD-YYYY') desc;" I am getting the expected result.
Is there an equivalent of this query in hibernate which I can use instead?


Top
 Profile  
 
 Post subject: Re: Problem while sorting datetime field based on date alone
PostPosted: Fri Jul 23, 2010 1:55 am 
Newbie

Joined: Thu Jul 22, 2010 2:39 am
Posts: 3
Can someone help me out to solve this problem?


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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.