extract year from date

how to extract the year from a date


The EXTRACT() function is a SQL standard function supported by MySQL, Oracle, PostgreSQL, and Firebird.

SELECT EXTRACT(YEAR FROM CURRENT_DATE)



If you use SQL Server, you can use the YEAR() or DATEPART() function to extract the year from a date.


SELECT YEAR(CURRENT_TIMESTAMP);

SELECT YEAR(CURRENT_TIMESTAMP);

SELECT DATEPART(year, CURRENT_TIMESTAMP);