MYSQL - date format change yyyy-mm
Posted on 2014-04-04
I have a question about mysql, which is new to me. I have a date formatted field, example 3/1/2014. I would like to convert this into 2014-03. It needs to have a padding for single digit months 1-9, to show 01, 02, 03.
I have tried a few ways but nothing works right.
update: I tried the following:
CONCAT(YEAR(EC.Date), '-', LPAD(MONTH(EC.Date), 2, '0')) as YEAR_MONTH and the output is
I tried parsing out yr and mo, I get the same ouput:
CONCAT(yr, '-', right(concat('00',mo),2)) AS yr_mo,