Anders Morken wrote:
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.
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. =)
Hi Sisilla,
This may be useful to you :
To return a timestamp value one month later than the current timestamp,
use the following syntax:
*{fn TIMESTAMPADD( SQL_TSI_MONTH, 1, CURRENT_TIMESTAMP)}*
So to return a timestamp value 5 days later than the current timestamp
the syntax is
*{fn TIMESTAMPADD( SQL_TSI_DAY, 5, CURRENT_TIMESTAMP)}*
So in your case it should be
values ({fn TIMESTAMPADD( SQL_TSI_DAY, 5, CURRENT_TIMESTAMP)});
For more reference
http://db.apache.org/derby/docs/dev/ref/rrefjdbc88908.html
Thanks
Manjula