Mysql: Defaulting a DATE field to current date
Jan.15, 2008 in
Tech
I recently came across the Mysql TIMESTAMP field type. I’ve seen this datatype for years, however have never really used it – until now. I’ve been looking for a way to set a fields value to the current date/time by default. You can’t do this with DATETIME field types in mysql, however you can do it with TIMESTAMP fields:
CREATE TABLE Person_Example( Person_Name VARCHAR(256), CreateDate TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP);
More information is available from the mysql manual.

Leave a Reply