• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

comparing dates in hibernate

 
shah rah
Ranch Hand
Posts: 124
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
Mark Spritzler
ranger
Sheriff
Posts: 17276
6
IntelliJ IDE Mac Spring
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic