MySQL DATETIME Question

Associate
Joined
3 Oct 2006
Posts
2,304
Location
London
Hi there,

Is there anyway to get a MySQL database to automatically insert the DATE and TIME, that the entry is created, into the entry you are creating? A bit like an auto incrementing number but for Date and Time I suppose!

Thanks

Jon
 
The field type IS date time, but it doesn't auto enter the date, it just leaves '0000-00-00 00:00:00'. This is the same whether it is set to NULL or NOT NULL (In the NULL Property)
 
Last edited:
Yeah, pretty much. A colleague at work said there was some kind of MySQL function now(). I've no idea how to use it though!
 
Code:
Error

SQL query:

ALTER TABLE `comments` CHANGE `comment_date` `comment_date` DATETIME NOT NULL DEFAULT 'SYSDATE()'

MySQL said: Documentation
#1067 - Invalid default value for 'comment_date'
 
Back
Top Bottom