> Hi, > > can anyone tell me how can i set the default datetime as current > datetime in the mysql. so that every time i insert a record in the table > current datetime automaticall inserted. > Thanks in advance.
>From MySQL manual section 6.5.3: "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." You have a couple options though, you can use a TIMESTAMP field which will be set to the current date/time when the data is inserted. But if the data changes, the timestamp field is updated again, so this will only work if you can be certain that you will not be updating the data after insertion. The other option is to use a DATETIME type column and use the following insert query: INSERT INTO mytable (col1, col2, ... , date_inserted) VALUES ('col1data', 'col2data', ... , NOW()); Josh --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php