Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CURRENT_DATE/CURDATE() not working as default DATE value

Pretty straight forward question here, I think this should work but it doesn't. Why doesn't it?

CREATE TABLE INVOICE(    INVOICEDATE DATE NOT NULL DEFAULT CURRENT_DATE ) 
like image 964
inControl Avatar asked Dec 09 '13 00:12

inControl


Video Answer


1 Answers

It doesn't work because it's not supported

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

http://dev.mysql.com/doc/refman/5.5/en/create-table.html

like image 52
zerkms Avatar answered Oct 02 '22 23:10

zerkms