get the year from a date in sql code example
Example 1: current year sql
-- Oracle
SELECT extract(YEAR FROM sysdate) FROM dual; // number
SELECT to_char(sysdate, 'YYYY') FROM dual; // varchar
Example 2: get current year sql
select year(getdate())
Example 3: extract year from date sql
SELECT extract(YEAR FROM sysdate) FROM dual; // number
SELECT to_char(sysdate, 'YYYY') FROM dual; // varchar
Example 4: sql get year from datetime field
SELECT YEAR(DateTimeField)
FROM MyTable