| Author |
date problem
|
Bill Walker
Greenhorn
Joined: Aug 22, 2002
Posts: 12
|
|
|
I have a string containing date of birth in mmddccyy format. How do I change it to a Date variable so I can insert it into a Date/Time database field?
|
 |
John Gooch
Greenhorn
Joined: Jun 25, 2002
Posts: 8
|
|
Here is some code that works with Oracle 8.1.7 where sSolDate = "2002-02-05" java.sql.Date d = java.sql.Date.valueOf(sSolDate); String sInsSol = "INSERT INTO ASFI_SOLICITATION " + "(SOLICITATION_NBR, AMMEND_NBR, RFQ_STATUS, CONTRACT_OFC_ID, SOLICITATION_DATE) " + " VALUES (?, ?, ?, ?, ? )"; try { PreparedStatement pInsertSol = cSolCon.prepareStatement(sInsSol); pInsertSol.setString(1, sSolNum); pInsertSol.setString(2, sAmendNum); pInsertSol.setString(3, sSolType ); pInsertSol.setString(4, sContractOfc ); pInsertSol.setDate(5, d ); pInsertSol.executeUpdate(); } catch (SQLException e) { System.err.println("Unable to create ASFI_SOLICITATION " + e); System.exit(1); }
|
 |
John Gooch
Greenhorn
Joined: Jun 25, 2002
Posts: 8
|
|
Here is some code that works with Oracle 8.1.7 where sSolDate = "2002-02-05" java.sql.Date d = java.sql.Date.valueOf(sSolDate); String sInsSol = "INSERT INTO ASFI_SOLICITATION " + "(SOLICITATION_NBR, AMMEND_NBR, RFQ_STATUS, CONTRACT_OFC_ID, SOLICITATION_DATE) " + " VALUES (?, ?, ?, ?, ? )"; try { PreparedStatement pInsertSol = cSolCon.prepareStatement(sInsSol); pInsertSol.setString(1, sSolNum); pInsertSol.setString(2, sAmendNum); pInsertSol.setString(3, sSolType ); pInsertSol.setString(4, sContractOfc ); pInsertSol.setDate(5, d ); pInsertSol.executeUpdate(); } catch (SQLException e) { System.err.println("Unable to create ASFI_SOLICITATION " + e); System.exit(1); }
|
 |
Bill Walker
Greenhorn
Joined: Aug 22, 2002
Posts: 12
|
|
|
I get an error that valueOf is not a method of java.sql.Date
|
 |
Jamie Robertson
Ranch Hand
Joined: Jul 09, 2001
Posts: 1879
|
|
give this a try:
|
 |
Bill Walker
Greenhorn
Joined: Aug 22, 2002
Posts: 12
|
|
|
Thats seems to work except I don't want the time attached to it. It's just a date of birth.
|
 |
 |
|
|
subject: date problem
|
|
|