Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Object search based on two dates and time

 
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.
 
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
 
author and cow tipper
Posts: 5000
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
 
Brace yourself while corporate america tries to sell us its things. Some day they will chill and use tiny ads.
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic