Add DATE and TIME fields to get DATETIME field in MySQL Add DATE and TIME fields to get DATETIME field in MySQL mysql mysql

Add DATE and TIME fields to get DATETIME field in MySQL


It should be as easy as

UPDATE table SET datetime_field = CONCAT(date_field, " ", time_field);


Both of the other answers do not convert the date properly if use use a TIME of "838:00:00" which is a valid time according to the mysql manual

so instead you can try converting the time field to seconds and then adding them
for example:

date_field + INTERVAL TIME_TO_SEC(time_field) SECOND

This will convert the date accordingly