• 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
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Insert a Date into DB JDBC

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 + "'} )";
 
author & internet detective
Posts: 42173
937
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
reply
    Bookmark Topic Watch Topic
  • New Topic