Extract year from a date in MySQL
Question:How to extract year from a date in MySQL?
SELECT id, YEAR(publish_date) AS publishYear FROM article WHERE YEAR(publish_date) = 2021;
In some cases, you only want to use the year part of a
DATETIME field. In this case, simply use the built-in
YEAR() function with the relevant field as the parameter.
YEAR() function returns the year for date, in the range 1000 to 9999, or 0 for the “zero” date.
Share "How to extract year from a date in MySQL?"
Tags:extract year, get year, year from date, get year from date, extract date from year
Technical term:Extract year from a date in MySQL