Page 1 of 1
Default Value for DATETIME field
Posted: Wed 05 Jul 2006 12:17
by poirazis
I am using the latest Developer Tool within VS2005, accessing a MySQL 5.0 server (on local host). I create a new table in my database, with a field of Type DATETIME, and I want the default value to be set to CURRENT_DATE. When I try to save the table though, I get an error that CURRENT_DATE , which is a mysql function, is not a valid value for my field. Any ideas ?
Regards
Michael
Posted: Fri 07 Jul 2006 06:30
by Alexz
There is a quotation from the MySQL documentation about your problem:
"..The DEFAULT clause specifies a default value for a column. With one exception, the default value must be a constant; it cannot be a function or an expression. 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. The exception is that you can specify CURRENT_TIMESTAMP as the default for a TIMESTAMP column as of MySQL 4.1.2.."
Re: Default Value for DATETIME field
Posted: Sat 12 Sep 2015 03:31
by dbforge noob
So how can we still accomplish this same task? I have the same issue with a Date column and would like it to automatically input the current date into that field when ever a new record is created.
Re: Default Value for DATETIME field
Posted: Mon 14 Sep 2015 12:42
by alexa
Could you please describe what exactly you are experiencing issues with as per the previously provided instruction?