-->
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: How to retrieve Data on the Basis on DATE Field
PostPosted: Thu Aug 19, 2004 11:14 am 
Newbie

Joined: Thu Aug 19, 2004 10:58 am
Posts: 3
I have been trying to retrieve records from the database that match a certain date. For that i have using following query :

query = session.createCriteria(Event.class)
.add(Expression.eq("dateOfEvent", objDate))
.list();

where event is mine bean class
objDate is of type java.util.Date (i have also tried it as java.sql.Date)

and dateOfEvent maps to Date_of_event (of type DateTime) in the SQL Server 2000 database.

But this query does not returns any thing.

Please help me out.


Sandy


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 19, 2004 11:21 am 
Newbie

Joined: Thu May 06, 2004 8:14 pm
Posts: 18
Using equality with Dates is not a great idea. You should use date ranges.

"where date > :start and date < :end"


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 25, 2004 2:26 am 
Newbie

Joined: Thu Aug 19, 2004 10:58 am
Posts: 3
mperham wrote:
Using equality with Dates is not a great idea. You should use date ranges.

"where date > :start and date < :end"


thanxs a lot.
the idea u gave worked beautifully.

but i was nit able to uderstand one thing that
for date < :end it returned me records with date less then end. fine

but for date > :start it returned me records having dates greater than and equal to start. why????????.

again thanx


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.