Reputation: 278
I have tried to make a column using datetime type in MySQL workbench.
but, when I select datetime type it occurs an error like
Could not set new data type The given data type DATETIME contains errors and cannot be accepted. The previous value is kept instead"
How can I use this type?
Upvotes: 22
Views: 62873
Reputation: 145
This may happen when you want to give column data type as varchar() with no parameter.
Please write the amount inside the data type like varchar(50).
Upvotes: 0
Reputation: 11
You need to add a value into the parenthesis. For example, use DATETIME(4) instead of DATETIME().
Upvotes: 0
Reputation: 3758
As of 5.6.4 TIME, TIMESTAMP and DATETIME can have a fractional part. To create a field with subseconds you can specify precision in brackets: TIME(3), DATETIME(6) etc.
time(3) = 05:05:10.000 (3 precision )
timestamp(6) = 2013-07-04 05:05:10.000000 (6 precision )
datetime(1) = 2013-07-04 05:05:10.0 (1 precision )
datetime = 2013-07-04 05:05:10 (0 precision )
Upvotes: 9
Reputation: 1
Re-create the initial workbench connection or reset the advanced connection properties to update the server version. If the server has been upgraded and the workbench connection is not updated the workbench still thinks it is working with the old version and therefore restricts and flags the datetime(x) as an error.
Upvotes: 0
Reputation: 902
I had this problem, you need to make sure that when you select the data type you change datetime() to datetime with no ().
From MySQL 5.6.4 onwards DATETIME can have subseconds, the level of precision being defined in the (), if you are not using subseconds then simply remove this all together. This also applies to the TIME and TIMESTAMP Datatypes.
Upvotes: 76