• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

comparing dates in hibernate

 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
this is how my date value is inside database (sqlServer)
2007-05-04 11:39:25.553, 2007-05-03 13:37:37.150

the user can enter date in mm/dd/yyyy(dfInputdatefmt) format. so I convert it to yyyy-MM-dd hh:mm:ss:SSS(dfOutputdatefmt) like this



Then I use

if I provide dateTo as 05/04/2007 and datFrom as 01/01/2007 ..it is missing all the 05/04/2007 records.

Whats wrong? Pls help me
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Think of dates as having time stamps. Do if you just put a Day, Month, Year, there is still a time element in there, like Midnight. So anything done in the day, like 4PM, happens before Midnight. That is why. If you want to compare at the day level, you need to convert both sides to just the Day, Month, Year and take out the time portion.

Mark
 
reply
    Bookmark Topic Watch Topic
  • New Topic