I am trying to use 'date-sub' to subtract few month using MySQL.
Before I do that, I figure I have to covert varchar(7) value into date format first.
So, I used following:
select str_to_date('7-2016', '%m-%Y'); -- 2016-07-00 (result)
The result was ok, but I am not sure why I get '-00'.
Now, I am trying to apply date_sub:
select date_sub(str_to_date('7-2016', '%m-%Y'), interval 11 month);
Why do I get null data?
Copyright Notice:Content Author:「Java」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/64359391/mysql-convert-from-varchar-to-date-and-applying-date-sub