Join date and time fields

I genuinely don’t know how often this comes up for others but I came upon an occasion where I needed to be able to combine date and time fields, which were stored separately within a MySQL database, into a single datetime field.

In my case I had a “date” field, a “time” field (which were both populated) and an empty “full_datetime” field which was NULL and needed populating.

UPDATE myTable

SET full_datetime = CONCAT(`date`, ‘ ‘, `time`)

 

try if you need

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s