Mega Code Archive

 
Categories / MySQL / Date Time
 

Extract the year part of the reference date and use normal arithmetic to add 10, 20, and 40 to it

mysql> mysql> SET @y = YEAR('2000-06-04'); Query OK, 0 rows affected (0.00 sec) mysql> SELECT @y + 10, @y + 20, @y + 40; +---------+---------+---------+ | @y + 10 | @y + 20 | @y + 40 | +---------+---------+---------+ |    2010 |    2020 |    2040 | +---------+---------+---------+ 1 row in set (0.00 sec) mysql>