Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dates in MySQL

 
Sean Casey
Ranch Hand
Posts: 625
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Sean Casey
Ranch Hand
Posts: 625
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 625
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the SQL statement I'm using:
ALTER TABLE users MODIFY regDATE TIMESTAMP(12);
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic