Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Oracle-JDBC Date handling and manipulation
saw a discussion the other week re. handling oracle dates. Oracle provides some simple tools for manipulation dates, see below.
My main problem at the moment is manipulating date properly between Oracle/Servlet, currently using the class12.zip jdbc driver from Oracle with the following connection string and typical select statements.
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
m_connection = DriverManager.getConnection(
"jdbc:oracle:thin:@my.path.to.my.server:1521:fred",info);
where 1521 is Oracle listener port number, fred is the name of my tablespace and info is
Properties info = new Properties(); info.put("user","myusername"); info.put("password","mypassword");
ResultSet rs = stmt.executeQuery("select * from temp"); String myattribname = rs.getString("myattribname");
now this is where I am having problems. I can select/insert/update Strings no problem. I have some data in date/number format in Oracle and I know the JDBC drivers support non-String formats but havnt found sample code yet to demonstrate.
Any suggestions/sample code would be appreciated. I'm currently looking at buying the Or'Reilly book on JDBC, any reviews/comments or other reccommendations would be appreciated.
Mat.
#######################
to get todays date
select sysdate from dual;
and to get date of a week from today,
select sysdate+7 from dual;
(ie add seven days)
and here are a few others
select sysdate from dual;
select sysdate+7 from dual;
select add_months(sysdate,1) from dual;
select add_months(sysdate,2) from dual;
select last_day(sysdate) from dual;
select months_between(sysdate, add_months(sysdate,6)) from dual;
select next_day(sysdate, 'Mon') from dual;
select next_day(sysdate, 'Wed') from dual;
select round(sysdate, 'Month') from dual;
select round(sysdate, 'Year') from dual;
these were taken from examples provided in the oracle on-line manual, refer http://your-path/database.804/a58225/ch3all.htm#999799 Received on Sat May 06 2000 - 00:00:00 CDT