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: Calculating Dates independent of the database (e.g. DATEADD)
PostPosted: Thu Oct 06, 2005 7:26 am 
Newbie

Joined: Thu Oct 06, 2005 7:11 am
Posts: 2
I try to add a number of days to a specific Date in my Table using Hibernate.

My App should work on MSSQL and PostgreSQL, so I try to find a global way for working with Dates because I don't want to implement different methods for each Database.

Using MSSQL should work like this

Code:
Iterator iterate = getHibernateTemplate().iterate("from Rechnung r where (r.mandant.id >= ?) and (r.mandant.id <= ?) and (DATEADD(day, 30, r.rechnungsDatum) <= ?)", ...)


PostgreSQL looks like this
Code:
terator iterate = getHibernateTemplate().iterate("from Rechnung r where (r.mandant.id >= ?) and (r.mandant.id <= ?) and ((r.rechnungsDatum + 30 as days) <= ?)", ...)


Please help.
THX


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 06, 2005 8:28 am 
CGLIB Developer
CGLIB Developer

Joined: Thu Aug 28, 2003 1:44 pm
Posts: 1217
Location: Vilnius, Lithuania
Implement custom date functions for both databases, this kind of function is very simple.


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.