-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 11 posts ] 
Author Message
 Post subject: Need help with Hibernate Query language - timestamp field
PostPosted: Thu Sep 29, 2005 4:28 am 
Newbie

Joined: Fri Sep 23, 2005 6:46 am
Posts: 12
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


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 29, 2005 4:31 am 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
why should people help you? you don't give credit.

http://forums.hibernate.org/viewtopic.php?t=948030&highlight=&sid=51ae791635573e8f09a68f8aca93e842


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 29, 2005 4:39 am 
Newbie

Joined: Fri Sep 23, 2005 6:46 am
Posts: 12
I am sorry. I missed out on the "credit" policy being followed. Let me see what I can do to rectify. :-)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 29, 2005 3:44 pm 
Beginner
Beginner

Joined: Tue Sep 06, 2005 5:16 pm
Posts: 24
Location: USA
Hi there how to give credit to some one..


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 29, 2005 3:48 pm 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
just log in to the forum, go to your topic, and click yes next to "Please rate this answer to give credits to the poster! Did it solve the problem?"


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 29, 2005 3:51 pm 
Beginner
Beginner

Joined: Tue Sep 06, 2005 5:16 pm
Posts: 24
Location: USA
Got it thanks dennisbyrne


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 29, 2005 3:53 pm 
Beginner
Beginner

Joined: Tue Sep 06, 2005 5:16 pm
Posts: 24
Location: USA
when i suggest some solution will the initiator of that topic be able to see the same link?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 29, 2005 3:55 pm 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
yes, they can see every post to topic.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 29, 2005 11:36 pm 
Newbie

Joined: Fri Sep 23, 2005 6:46 am
Posts: 12
Hi

I am sorry I didnt rate your earlier response. I wasnt watching the topic and I got the solution I was looking for from another forum.
Anyway I have rated your response that I dont rate. :-)

I havent solved my problem yet, so if someone out there does know the answer please respond.

Thanks,
Dhanya


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 30, 2005 12:56 am 
Senior
Senior

Joined: Tue Jun 21, 2005 10:18 am
Posts: 135
Location: South Carolina, USA
Dhanya wrote:
Hi
I havent solved my problem yet, so if someone out there does know the answer please respond.


As far as I know, you can't exactly do this. After all, even with java.sql.Date, the time portion is simply zeroed out. Instead, you would probably be better off rewriting your query slightly as:
Code:
select fe from ForwardEntry fe
where fe.myTxTs >= :startDate
and fe.myTxTs < :endDate


and then setting startDate to the target date, and end date to the target date + 1 day (make sure that the time is zeroed out (midnight) for both dates). The change from <= to < in the query will ensure you don't get any timestamps after the specified end date.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Sep 30, 2005 1:09 am 
Newbie

Joined: Fri Sep 23, 2005 6:46 am
Posts: 12
Thanks for your response but this worked:

where date(fe.myTxTs)>=:startDate
and date(fe.myTxTs)<=:endDate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 11 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.