File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes inserting date and time into database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "inserting date and time into database" Watch "inserting date and time into database" New topic
Author

inserting date and time into database

sundeep
Greenhorn

Joined: Apr 20, 2001
Posts: 5
can any one help me regading inserting and retriving date and time into and from database ..using sql
thanks in advance
Balki Dhar
Greenhorn

Joined: Dec 15, 2005
Posts: 18
Which database you are using? What is your JDBC driver?
Balki
sundeep
Greenhorn

Joined: Apr 20, 2001
Posts: 5
i am using ms access database
connecting to database , inserting and retriving from database of strings and numbers for me working ...problem is with inserting and retriving date and time into the data base
Carl Trusiak
Sheriff

Joined: Jun 13, 2000
Posts: 3340
To insert/retrieve a date, you need to construct an insert statement in your java program that uses the functions in Access that convert to/from a string to the date data type.
Format converts from a date to a string for retrieving the date from the database and DateValue converts a string to a Date.


I Hope This Helps
Carl Trusiak, SCJP2, SCWCD
Todd M Bush
Greenhorn

Joined: Apr 26, 2000
Posts: 22
I know using an Oracle database and Oracle's JDBC driver I can insert a date using this...
sSql = "insert into myTable value( {d '" + myDate + "'}";
The {d 'date' } is read my the JDBC driver and formats the date to the odd way Oracle stores it. myDate is a String formatted like "mm/dd/yyyy".
Whichever JDBC driver you are using might have the same functionality.
Hope this helps
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: inserting date and time into database
 
Similar Threads
inserting date and time into database
Save Logout time in database
Java date to MySQL date conversion
How to insert Date data in Oracle database in MM/DD/YYYY HH:MM:SS format?
Inserting date in database