Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Object search based on two dates and time

 
Abhi Bhatambrekar
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I need an urgent help regarding searching records from database between two dates and time using hibernate.

e.g. I need to retrieve records from an object, say TestClass, which exists between 09/Jun/2009 12:57 PM to 11/06/2009 12:57 PM.

I tried with using Criteria, but search is not working as per the expectations.

Can anyone help me please?

Thanks.
 
Rahul Babbar
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A similar post related to dates was here

Basically you may want to use one or more of the following functions provided by hibernate

CURRENT_DATE(),
CURRENT_TIME(),
CURRENT_TIMESTAMP(),
MONTH(<date>)
YEAR(<date>)
DAY(<date>)...etc
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rahul is correct. Sometimes using times and dates can be difficult with the Criteria API.

-Cameron McKenzie
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic