Reputation: 435
I have a column date like
date CHAR(7) CHARACTER SET LATIN NOT CASESPECIFIC,
where i have some values like 2010-12, 2011-10, etc. i want to change these into the date format yyyy/mm . How do i do it?
Thanks
Upvotes: 4
Views: 5589
Reputation: 60482
Simply apply a FORMAT dring the CAST:
SELECT CAST('2010-12' AS DATE FORMAT 'YYYY/MM')
This returns a valid date with the day set to the 1st of this month.
Upvotes: 5