Beginner

114. Extract Year

Learn how to extract the year component from a date.

📘 Lesson 114 of 728 ⏱ 7 min 🎯 Beginner

Extracting the year means retrieving the four-digit year component from a date or timestamp. SQL provides different functions for this depending on the database system.

Year-based analysis is one of the most common requirements in business reporting.

An analyst can extract the year from OrderDate and calculate total sales for each year.

SQL
SELECT
    EXTRACT(YEAR FROM OrderDate) AS OrderYear,
    SUM(SalesAmount) AS TotalSales
FROM Sales
GROUP BY EXTRACT(YEAR FROM OrderDate);

Year extraction is useful for annual sales reports, financial analysis, employee joining trends, and long-term business comparisons.

  • Year can be extracted from dates.
  • Year extraction supports annual analysis.
  • EXTRACT is one common SQL approach.
  • Database-specific functions may also be available.
  • Year can be used with GROUP BY.
How can you extract a year from a date?

You can use EXTRACT(YEAR FROM date) or a database-specific year function.

Why extract year from a transaction date?

It allows transactions to be grouped and compared by year.

Have you finished this lesson?

Introduction to SQL – All Lessons