Default Value for DATETIME field

Discussion of open issues, suggestions and bugs regarding database management and administration tools for MySQL
Post Reply
poirazis
Posts: 36
Joined: Mon 23 Jan 2006 16:08

Default Value for DATETIME field

Post by poirazis » Wed 05 Jul 2006 12:17

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

Alexz
Devart Team
Posts: 165
Joined: Wed 10 Aug 2005 08:30

Post by Alexz » Fri 07 Jul 2006 06:30

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.."

dbforge noob
Posts: 3
Joined: Tue 03 Feb 2015 02:51

Re: Default Value for DATETIME field

Post by dbforge noob » Sat 12 Sep 2015 03:31

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.

alexa

Re: Default Value for DATETIME field

Post by alexa » Mon 14 Sep 2015 12:42

Could you please describe what exactly you are experiencing issues with as per the previously provided instruction?

Post Reply