Hello
I have a table for messages, and when a new message is inserted I want the current date and time to be inserted into the MessageDated and MessageTimed fields. I'm using MySQL 3.23.56 (?), with Chilisoft ASP, and using the MySQL Control Center interface.
The problem is that no matter what I try, I seem to end up with 00000000000000 in the fields instead of the current date and time. For example, I have two hidden fields in my insert form, called MessageDated and MessageTimed, each set to <% = now() %>. I have the fields in the database set to DATETIME and also with default value 'now()'. But this doesn't seem to work.
How can I get the default value to be now()? The only way I've succeeded is by setting the type of field to VARCHAR, but that's not ideal.
Thanks in advance for any help you can give me!
http://www.mysql.com/doc/en/CREATE_TABLE.html says:
Default values must be constants. This means, for example, that you cannot set the default for a date column to be the value of a function such as NOW() or CURRENT_DATE.
So what you should do is set those two columns explicitly to NOW() when you create new records.
Best wishes
Trevor
-- Paul DuBois, Senior Technical Writer Madison, Wisconsin, USA MySQL AB, www.mysql.com
Are you MySQL certified? http://www.mysql.com/certification/
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]