I want to run a SELECT query on table which picks up the date stored in the year_end field and automatically treats it as being that occurrence of the date in the last 12 months.
I.e.: today is May 14th so:
If I have 2012-01-01 then I want that unchanged
If I have 2010-05-05 then I want 2012-05-05
If I have 2012-10-10 then I want 2011-10-10
Any ideas on the SELECT I need please?
Here is what you need:
Here are the three dates you chose as examples + 2 leap year dates
Here they are executed
mysql> set @mydate = ‘2012-01-01’;
Query OK, 0 rows affected (0.00 sec)
Give it a Try !!!