title: mysql - converting datetime column to timestamp
body: <p>I am trying to convert datetime columns of my database to timestamp without data loss. I followed this answer:
  <a href="https://stackoverflow.com/questions/16351106/bulk-convert-and-update-datetime-column-values-to-unix-timestamp">Bulk convert and update datetime column values to UNIX timestamp?</a></p>
  
  <p>but when I want to:</p>
  
  <pre><code>UPDATE `members` SET `new_join_date` = UNIX_TIMESTAMP(`join_date`), `new_last_visit` = UNIX_TIMESTAMP(`last_visit`);
  </code></pre>
  
  <p>I get this error:</p>
  
  <pre><code>#1292 - Incorrect datetime value: '1376833381' for column 'new_join_date' at row 1
  </code></pre>
  
  <p>full convertion queries:</p>
  
  <pre><code>ALTER TABLE `members`
  ADD COLUMN `new_join_date` TIMESTAMP NULL AFTER `join_date`,
  ADD COLUMN `new_last_visit` TIMESTAMP NULL AFTER `last_visit`;
  
  UPDATE `members`
  SET `new_join_date` = UNIX_TIMESTAMP(`join_date`),
  `new_last_visit` = UNIX_TIMESTAMP(`last_visit`);
  
  ALTER TABLE `members` DROP `join_date`;
  
  ALTER TABLE `members` DROP `last_visit`;
  
  ALTER TABLE `members` CHANGE `new_join_date` `join_date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP;
  
  ALTER TABLE `members` CHANGE `new_last_visit` `last_visit` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP;
  </code></pre>