I have been sent a url for datetime explanations in the MySQL manual. I have learnt a few things, but I am also more confused than ever.

I am trying to create a couple of columns (one createddate and one updateddate) in a MySQL table that are DATETIME or TIMESTAMP values, but I am having trouble understanding how it works. I want both columns to auto add a date and time when a record is first inserted, but only the updateddate column to update when the record is updated.

Could someone give me the code for these two columns please? This is what I have:

CREATE TABLE all_articles (
id SMALLINT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
createddate DATETIME DEFAULT "0000-00-00 00:00:00"
updateddate DATETIME DEFAULT "0000-00-00 00:00:00"
article TEXT
);

Obviously these aren't going to auto add/update because I am not stating a NOW() or NULL value anywhere, but I thought this would be the cleanest way to give it to you. The way the zeros, hyphens and colons are typed is how I would like to store my dates if at all possible.

TIA

Mat


-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to