Creating DATETIME from DATE and TIME

前端 未结 6 1447
后悔当初
后悔当初 2020-12-05 04:23

Is there way in MySQL to create DATETIME from a given attribute of type DATE and a given attribute of type TIME?

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-05 04:38

    select timestamp('2003-12-31 12:00:00','12:00:00'); 
    

    works, when the string is formatted correctly. Otherwise, you can just include the time using str_to_date.

    select str_to_date('12/31/2003 14:59','%m/%d/%Y %H:%i');
    

提交回复
热议问题