-->
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.  [ 2 posts ] 
Author Message
 Post subject: How to work with date in Named query
PostPosted: Thu Sep 08, 2005 2:30 pm 
Newbie

Joined: Mon Jun 06, 2005 8:53 am
Posts: 16
Hi,

How can I do this SQL statement using a HQL (named query)?

select * from mytable
where
date(mydate) > date(current date) and
date(mydate) < date(current date) + 60 days;

If I insert the date() I get an error on the named query when I start the server.

Any idea?

Thanks,
Cristiane


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 08, 2005 2:59 pm 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
to set today's date, use the Query class's setters for named parameters and just write some named parameters into your query

Code:
Query q = session.getNamedQuery("myquery");
q.setParameter("todaysdate", todaysDate);

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


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