5 messages in com.mysql.lists.mysqlre: Default Date/Time Issues
FromSent OnAttachments
Ray, Jason08 May 2003 05:38 
TheMechE08 May 2003 09:19 
Egor Egorov12 May 2003 03:48 
Nick Arnett12 May 2003 07:26 
James Moe13 May 2003 10:19 
Subject:re: Default Date/Time Issues
From:Egor Egorov (egor@ensita.net)
Date:05/12/2003 03:48:38 AM
List:com.mysql.lists.mysql

On Thursday 08 May 2003 19:19, TheMechE wrote:

I'm running 4.0.6-gamma mysql engine,

I'm having trouble making my dates function properly on several levels. For instance, setting a timestamp field (which I thought would result in always timestamping the time the row was inserted) is always resulting in 0000-00-00 as its default. (Manual Reference page 556 of MYSQL by PaulDuBois Third paragraph from the bottom of the page.)

In addition, while the sql below gets accpeted by the server, and the table is created....

CREATE TABLE `Test` (`int` integer AUTO_INCREMENT , `posted` datetime NOT NULL DEFAULT 'CURDATE()' , PRIMARY KEY (`int`)) TYPE=MYISAM PACK_KEYS=DEFAULT ROW_FORMAT=DEFAULT

It fails to use CURDATE() (Or any other amalgamation of date/time functions) as its default. It also only returns 0000-00-00 00:00:00 as its value when a row is inserted. Can I not use functions as defaults?

Can anyone explain why this occurs? Does table type affect the ability to use defaults for datetime columns?

You can't use functions as default values. Take a look at TIMESTAMP column type: http://www.mysql.com/doc/en/DATETIME.html