Merge date from one datetime and time from another datetime

前端 未结 1 616
鱼传尺愫
鱼传尺愫 2021-01-28 21:03

I\'m maintaining a database where the date and the time of events are seperated, both are saved as datetime though.

So How do I pull the date from the \"date\" Column, a

相关标签:
1条回答
  • 2021-01-28 21:30

    You can use the DATE_FORMAT function in your selects.

    For the date:

    '%Y-%m-%d'
    

    For time:

    '%H:%i:%s'
    

    So something like:

    UPDATE `table`
    SET `datetimecol` = CONCAT_WS(' ', DATE_FORMAT(`datecol`, '%Y-%m-%d'), DATE_FORMAT(`timecol`, '%H:%i:%s'))
    
    0 讨论(0)
提交回复
热议问题