Get current year in MySQL
Question:
How to get current year in MySQL? Answer:
SELECT id, deadline, YEAR(CURDATE()) AS 'currentYear'
FROM task WHERE YEAR(deadline) = YEAR(CURDATE());
Description:
In case you only want to know the actual year without month and day use the built-in YEAR()
function with CURDATE()
as the parameter.
YEAR()
returns the year for date, in the range 1000 to 9999, or 0 for the “zero” date. Returns NULL if date is NULL.
Reference:
YEAR reference
Share "How to get current year in MySQL?"
Related snippets:
Tags:
current year, actual year, get year, get current year, mysql Technical term:
Get current year in MySQL