Search code examples
mysqldatabase-migration

Migration of mysql dates in integer format


I want to migrate dates from integer format to DATETIME.

My dates in my old database have the following format:

olddb.table.date = 20131114 (INT) olddb.table.time = 900 (INT) (9 AM, 24h clock)

new database:

newdb.table.datetime = 2013-11-14 9:00:00 (DATETIME)

How would I migrate this with purely SQL?


Solution

  • SELECT CAST(CONCAT(DATE(olddb.table.date),' ',TIME(olddb.table.time*100)) AS DATETIME);