Answer the question
In order to leave comments, you need to log in
How to change TIMESTAMP value?
Good day! I have a database that has a field with "TIMESTAMP" by default. And it saves the date in YYYYMMDDHHMMSS format, and I would like to change it to "TIMESTAMP(8)" YYYYMMDD. When I try to set the value, phpMyAdmin gives me an error.
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(8) NOT NULL DEFAULT CURRENT_TIMESTAMP' at line 1
Answer the question
In order to leave comments, you need to log in
It can create an intermediate tmp table, for example, with the required fields and the correct format
. And then insert the values in the desired format there.
DATE_FORMAT(column_name, '%Y%m%d')
Type,
INSERT INTO tmp ( ts8 )
SELECT DATE_FORMAT(ts_name, '%Y%m%d')
FROM table
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question