Convert MySQL datetime to timestamp Convert MySQL datetime to timestamp mysql mysql

Convert MySQL datetime to timestamp


UPDATE table1 A, table2 B SET B.date_added=UNIX_TIMESTAMP(A.date_added) WHERE A.id=B.id;

UNIX_TIMESTAMP('2015-01-15 12:00:00');is sufficient to convert a mysql datetime to a Timestamp.


Try this please:

UPDATE table1 A, table2 B SET B.date_added = FROM_UNIXTIME(A.date_added) WHERE A.id=B.id

Reference.It seems like you have an issue with the way you format date stammp.Also please look into this post: Should I use field 'datetime' or 'timestamp'?


On MySQL 5.5 this works fine:

UPDATE `some_table`SET `timestamp_col` = `datetime_col`

with datetime_col of type DATETIME and timestamp_col of type TIMESTAMP.

That is: no needs of explicit type conversion.