dallas dallas - 5 days ago 5
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

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

sample

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

result

2016-04-01
Comments