-->
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: Criteria, to_date
PostPosted: Fri Dec 15, 2006 6:12 pm 
Newbie

Joined: Fri Dec 15, 2006 5:49 pm
Posts: 1
Hi, I have a little problem. I have dates with different hours in my database, and I want to use the function to_date in order to only obtain the date but I don't know how?

Here my criteria:

DetachedCriteria criteria = DetachedCriteria.forClass(SomeClass.class);
criteria.add(Restrictions.between("date1", someDto
.getDate1(), someDto.getDate2()));

I tried to do this:

DetachedCriteria criteria = DetachedCriteria.forClass(SomeClass.class);
criteria.add(Restrictions.between("to_date(date1)", someDto
.getDate1(), someDto.getDate2()));

jojojo but it doesn't work :D.

Any idea?, Some hint?

Thank you very much.

PS: I'm using Oracle9i and java.util.Date


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 15, 2006 6:56 pm 
Expert
Expert

Joined: Tue Dec 28, 2004 7:02 am
Posts: 573
Location: Toulouse, France
If I were you, I would the conversion in Java, for example, creating the same day date at 00h00m00s instead of another, then passing it to the db query. I don't think it would cost something noticeable in perfs. If you really want to use to_date, I'm not sure it will be possible without doing an SQL-Query.

_________________
Baptiste
PS : please don't forget to give credits below if you found this answer useful :)


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.