This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes Dates in MySQL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Dates in MySQL" Watch "Dates in MySQL" New topic
Author

Dates in MySQL

Sean Casey
Ranch Hand

Joined: Dec 16, 2000
Posts: 625
Does anyone know how to record times or dates in a column in a table? I have a table that the first column is an id column that is auto incremented, then I have another column that I want a date recorded for every row that is inserted into the table I've tried timestamp and DATETIME using the mysql reference but haven't gotten it to work yet?
Kareem Gad
Ranch Hand

Joined: Aug 06, 2001
Posts: 89
Timestamp is your only date option
it comes in different flavours
timestamp
timestamp(2)
timestamp(4)
timestamp(8)
timestamp(12)
timestamp(14)
2: 2 digit year representation
4: yymm
8: yyyymmdd
12: yyyymmddhhmm
14: yyyymmddhhmmss
got it?

------------------
KaReEm


<b><i>KaReEm</i><br /><ul type="square"><li>SCJP-Free Range Web Developer <br /></ul></b>
Sean Casey
Ranch Hand

Joined: Dec 16, 2000
Posts: 625
Thanks for your reply.
I know all the versions of TimeStamp, I just can't get them to work in a column. When I try to designate it. It comes up 000000 instead of giving a date.
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

Originally posted by Sean Casey:
Thanks for your reply.
I know all the versions of TimeStamp, I just can't get them to work in a column. When I try to designate it. It comes up 000000 instead of giving a date.

what is the code that is giving you the undesired results?
Sean Casey
Ranch Hand

Joined: Dec 16, 2000
Posts: 625
This is the SQL statement I'm using:
ALTER TABLE users MODIFY regDATE TIMESTAMP(12);
 
Have you checked out Aspose?
 
subject: Dates in MySQL
 
It's not a secret anymore!