SQL · Pattern 3 — Built-in Functions
Date Functions
Date functions extract or manipulate parts of a date — YEAR(), MONTH(), DATEDIFF(), CURRENT_DATE.
Source data — Pattern 3: Built-in Functions
All queries run against the shared employees table (see schema.sql). This pattern needs two columns not used before: hire_date (topic 17) and bonus, nullable (topics 19–20).

What it does
Date functions extract or manipulate parts of a date — YEAR(), MONTH(), DATEDIFF(), CURRENT_DATE. "This year" isn't a fixed value, so the query needs to compare against whatever the database considers today, not a hardcoded year.
Problem
Find employees hired this year.
-- MySQL
SELECT *
FROM employees
WHERE YEAR(hire_date) = YEAR(CURDATE());
-- PostgreSQL / Oracle / standard SQL
SELECT *
FROM employees
WHERE EXTRACT(YEAR FROM hire_date) = EXTRACT(YEAR FROM CURRENT_DATE);
Result
