>>>>>>>>>>>> Anders Morken wrote (2007-01-31 15:49:46):
> Sisilla:
> > How do I insert a date value of 5 days after the current date to a column
> > called 'responseDate' in a table called 'quotationRequest'? Perhaps, it
> > would be similar to the following?-:
> > 
> > INSERT INTO quotationRequest (responseDate) VALUES (DATE(current_date + 5
> > DAYS))
> > 
> > I appreciate any effort to help me. Thank you for your time and
> > consideration.

You may use timestampadd which is defined as an escape syntax in the
JDBC spec. Example:

ij>  values cast({fn timestampadd(SQL_TSI_DAY, 5, current_timestamp)} as date);
1         
----------
2007-02-05

See the Derby reference manual for more details.


> 
> I don't think Derby provides this in SQL - but Java provides this in the
> API:
> 
> ps = connection.prepareStatement("INSERT INTO quotationRequest (responseDate) 
> VALUES (?)");
> 
> Date responseDate = (new GregorianCalendar()).add(Calendar.DAY_OF_MONTH, 
> 5).getDate();
> 
> ps.setDate(1, responseDate);
> rowsChanged = ps.executeUpdate();
> 
> Kinda hackish, might not be correct or do exactly what you want, but you
> get the idea. =)
> 
> (Note that the calendar classes in java.util are known for being...
> somewhat eccentric. Cavet emptor. =)
> 
> -- 
> Anders Morken
> 
> My opinions may have changed, but not the fact that I am right!

-- 
Bernt Marius Johnsen, Database Technology Group, 
Staff Engineer, Technical Lead Derby/Java DB
Sun Microsystems, Trondheim, Norway

Attachment: pgpIEGqlRCydi.pgp
Description: PGP signature

Reply via email to