Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need help with Hibernate Query language - timestamp field

 
dhanya kairali
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a timestamp field in DB. I want to fetch those rows in DB whose timestamp falls between 2 dates.
I have tried this
select fe from ForwardEntry fe
where fe.myTxTs>=:startDate
and fe.myTxTs<=:endDate

If the time stamp falls on 12/12/2005 05:00 am I want that to be displayed when I specify my start and end date as 12/12/2005. This is not working cos the time field is not matching. How can I format the timestamp field in the query so that the date part alone is considered?

Thanks in advance,
Dhanya
 
Thomas Bigbee
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would be more that happy to help, however, please note that I am a Hibernate Newbie myself. The below code works against a MySQL DataBase, the field on_date in the database is really a TimeStamp field, I know I should have named it on_timestamp, however, it works and I'm just too damn lazy to rewrite the code and database, also please be kind when reviewing the code, this may not be production grade, but at least it works.



 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic