Home mysql current_timestamp for mysql

current_timestamp for mysql




If the field has a date format, you can make auto insert current dates for the muscle forces like current_timestamp for TimeStamp ?

Answer 1, Authority 100%

No, TimeStamp is an exception. For other data types, only constants can be used as Default.
In the documentation http://dev.mysql.com/doc/refman/5.5/en/ Create-Table.html

Default value Specifies the default value for the table field with one exception: the default value must be a constant, it cannot be a function or expression. For example, you cannot specify the value of the NOW () or CURRENT_DATE function for the DATE field. Exception: You can set CURRENT_TIMESTAMP as default value for TimeStamp field.

However, there are options:

  1. Use timestamp as data type.
  2. make a trigger that implements the required functionality.

Answer 2

I suggest the following solution:

convert (Current_TimeStamp, Date)

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions