* Matthew Stuart > I am trying to get MySQL to automatically create a date seven days from > the date a new record is created. The new records will be inserted > through an ASP, VBScript website. I have managed to get this to work in > MS Access by typing in to its default field in the database Now()+7. As > you would expect, it gives me a date 7 days from now. > > I have tried the same with MySQL and it keeps throwing the default I > type out and replacing it with 0000-00-00 00:00:00
You can't use a function as a default value in mysql. The special data type TIMESTAMP will use NOW() as a default value, but you can't use NOW()+7 or any other expression involving a function as a default value. What you need to do is include your expression in the INSERT statement: INSERT mytable SET mycol1="something",starttime=NOW(),endtime=NOW()+7; Now, this will set the endtime 7 _seconds_ into the future. If you want it to be 7 _days_, you could use something like this: INSERT mytable SET mycol1="something",starttime=NOW(), endtime=NOW()+INTERVAL 7 DAY; ...or for older versions, before release 3.23.4 (28 Sep 1999): INSERT mytable SET mycol1="something",starttime=NOW(), endtime=DATE_ADD(NOW(),INTERVAL 7 DAY); <URL: http://www.mysql.com/doc/en/DATETIME.html > <URL: http://www.mysql.com/doc/en/Date_and_time_functions.html > -- Roger -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]