• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

date problem

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I get an error that valueOf is not a method of java.sql.Date
 
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
give this a try:
 
Bill Walker
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thats seems to work except I don't want the time attached to it. It's just a date of birth.
 
Yeah, but does being a ninja come with a dental plan? And what about this tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic