Skip to main content
SQL • LESSON 127

Extract Year

How can we extract the numerical year from an order date?

Advanced3 Minutes1400 XP
🤔 THE QUESTION

How can we extract the numerical year from an order date?

💡 WHAT IS IT?

EXTRACT(YEAR FROM date) extracts the calendar year integer from timestamps or date fields.

🎯 WHAT IS IT USED FOR?

Annual aggregations, cohort classification, annual growth modeling.

💻 EXAMPLE
SELECT
order_id,
EXTRACT(YEAR FROM order_date) AS order_year
FROM orders;

🎯 Mission Objectives

Practice typing production-grade SQL code for Extract Year.

  • EXTRACT(YEAR ...)
  • Date component extraction
  • Year attribute
  • Temporal projection