-->
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.  [ 4 posts ] 
Author Message
 Post subject: How to use Restrictions on Date Part ?
PostPosted: Wed Jun 29, 2005 5:40 am 
Beginner
Beginner

Joined: Wed Aug 25, 2004 10:27 pm
Posts: 21
Location: Indonesia
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.0.5

Name and version of the database you are using: SQL Server 7.0 / 2000

Hi all,

I have the following SQL statement :

SELECT * FROM Orders WHERE MONTH(OrderDate) = 1

I need help on using Criteria & Restrictions to produce the same results as above query.

Thanks in advance.


Setya


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 15, 2005 12:14 pm 
Newbie

Joined: Tue Apr 13, 2004 11:34 am
Posts: 4
I have a somewhat similar question, and can't seem to find an answer on these forums. We have a table with a timestamp column, but would like to perform a query ignore the time part of that column, just the date. In SQL, something like:

select * from orders where TRUNC(order_date) <= TO_DATE('07/16/2005', 'mm/dd/yyyy')

to get all orders from today, regardless of time. How can this be accomplished using the criteria API?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jul 19, 2005 10:09 am 
Newbie

Joined: Tue Apr 13, 2004 11:34 am
Posts: 4
so is this not possible?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jul 24, 2005 12:26 pm 
Beginner
Beginner

Joined: Fri Jul 08, 2005 8:09 am
Posts: 28
cheath wrote:
select * from orders where TRUNC(order_date) <= TO_DATE('07/16/2005', 'mm/dd/yyyy')


I do this by adding one day to the date first, and setting the time portion to zero. Something like this (in your case):

Code:
order_date < '07/17/2005'


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.