mySQL convert varchar to date
Posted
by
Jeff V
on Stack Overflow
See other posts from Stack Overflow
or by Jeff V
Published on 2011-01-16T15:45:35Z
Indexed on
2011/01/16
15:53 UTC
Read the original article
Hit count: 119
mysql
I need to convert a varchar value of 1/9/2011 to a date in mySQL and I want only the month and year. So that I can then use the PERIOD_DIFF function (so I would need the above to be converted to 201101).
I've tried various ways using the STR_TO_DATE function:
SELECT STR_TO_DATE(CYOApp_oilChangedDate, '%m/%Y') FROM CYO_AppInfo
But I get weird results... (for example: 2009-01-00)
What am I doing incorrectly?
© Stack Overflow or respective owner