You can't use a default value of NOW(), to the best of my knowledge.  However,
if your INSERT statement is properly formatted, you should have no problem
getting it to do as you please.  Personally, rather than having two hidden form
fields, I'd just setup my INSERT statement as follows (using PHP for the
example):

$query = "INSERT INTO table (field, messageDated)
    VALUES( \"".$value1."\", NOW() )";

Being that the messageDated and messageTimed (not shown in example) fields
aren't user variables, there's no problem with hard-coding them into the insert
statement.

Edward Dudlik
Becoming Digital
www.becomingdigital.com


----- Original Message -----
From: "Trevor Sather" <[EMAIL PROTECTED]>
To: "[EMAIL PROTECTED] Mysql. Com" <[EMAIL PROTECTED]>
Sent: Monday, 09 June, 2003 19:23
Subject: Default Datetime?


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!

Best wishes

Trevor




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

Reply via email to