limited time offer

Write an sql query to find the year from date using MySQL ?

You can use either Date_Format() or Year() function.

Date_Format() to find Year

SELECT DATE_FORMAT('2015-07-08', '%Y');
SELECT DATE_FORMAT(NOW(), '%Y');
SELECT DATE_FORMAT(CURDATE(), '%Y');

first query will return 2015 and remaining 2 will return current year.

YEAR() to find Year

SELECT YEAR('2018-07-08');
SELECT YEAR(NOW());
SELECT YEAR(CURDATE());

first query will return 2015 and remaining 2 will return current year