-->
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: Add days to date field?
PostPosted: Tue Jan 25, 2005 2:02 am 
Newbie

Joined: Tue Jan 25, 2005 1:58 am
Posts: 3
Hi All!

I have a type persisted through Hibernate that has a java.util.date field. I would like to do a query based on a date calculation. For example:

WHERE record.date + [[30 days..]] > [[current date]]

Can someone tell me how to express these two things or let me know where I can find out?

Thanks for any assistance!

Rob
:)


Top
 Profile  
 
 Post subject: Re: Add days to date field?
PostPosted: Sun May 31, 2009 5:54 pm 
Beginner
Beginner

Joined: Wed Sep 06, 2006 12:08 pm
Posts: 48
Location: Warsaw - Poland - Europe - Milky Way
Hi

I had similar "problem".

My proposition of solution is something like this:
Code:
         em
            .createQuery("from MyTable where entTime < :date")
            .setParameter("date", new Timestamp(System.currentTimeMillis() - [30 days..]))
            .getResultList();


Hope, this helps :)

Regards,
Adam Woźniak


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.