Try this
SET Period = STR_TO_DATE(CONCAT('01-', @var1),'%d-%b-%y')
Pregunta
T've the date column with value like 'May-10' (Say %b-%y format).While loading data to mysql, i use like
SET Period = STR_TO_DATE(@var1,'%b-%y')
Then the values are stored as '2013-05-00'. But i want to save those values in any date number (say '2013-05-01').
I tried like doing this for May-10
DATE_ADD(DATE_SUB(DATE_FORMAT(LAST_DAY(STR_TO_DATE('May-10','%b-%y')),'%Y-%m-%d' ),INTERVAL 1 MONTH),INTERVAL 1 DAY)
I know that this is a complex way of doing things.
Anyone please suggest me simple solutions ?
Solución
Try this
SET Period = STR_TO_DATE(CONCAT('01-', @var1),'%d-%b-%y')