dallas dallas - 1 year ago 96
SQL Question

Converting Mysql text to date

I currently am working with a database that has a month column and a year column.. Both are of type text. Month is stored as 'January' and year is stored as you would expect, '2016'..

Any recommendations for concatenating these and converting them to a date type?

Answer Source

You can use a query like this. you only must change the strings to your fieldnames:


select STR_TO_DATE(concat('2016',' ','April','1'), '%Y %M %D');


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download