Reputation: 55
I have a column values like 20150921. I want to convert this string value to a specified date format like 2015-09-21 in mysql.
Upvotes: 1
Views: 60
Reputation: 962
I am able to run this query on my MySql 5.6.
SELECT DATE('20150921');
So i believe, this should work directly DATE(colStringDate)
Upvotes: 0
Reputation: 172638
Try this:
date_format(str_to_date('20150921', '%Y%m%d'),'%Y-%m-%d')
(Assuming that you want your date format to be in YYYY-MM-DD format)
Upvotes: 2