I have upgraded my Mysql version from Mysql5.0 to Mysql5.5,
This is query returning null but same query was returning value before upgrade.
SELECT DATE_FORMAT(DATE_ADD(STR_TO_DATE('2010-04', '%Y-%m'), INTERVAL 2 YEAR),'%Y-%m')
Should return 2012-04
My date values are of varchar type I want to add interval of 2 years.
Is there any other way to achieve this OR Please tell me how to correct it?
Mysql version > 5.0
str_to_date()sometimes would returnNULLif the%Dformat specifier is not the last specifier in the format string input.You need to apply some trick (specify
%Dhere ).Try below: