• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Insert a Date into DB JDBC

 
Eric Qez
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to insert a date variable into DB. The field in DB table is date. The date is in default format 'yyyy-mm-dd'. I try to use statement like this and didn't work. Any idea?
String wkEnding = "2004-01-19";
sql = "Insert into Timesheet Wk_Ending values( {d '" + wkEnding + "'} )";
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eric,
It's generally a good idea to use a prepared statement. That way, you do not have to worry about db specific formats.
What db are you using?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic