tags:

views:

29

answers:

1

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, and the time from the "time" column and insert it into the "datetime"-column

+2  A: 

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'))
jasonbar
GREAT! It worked wonderful!
Gnutt