Beginner

278. DAYOFYEAR Function

Learn how to determine the position of a date within its year.

📘 Lesson 278 of 728 ⏱ 9 min 🎯 Intermediate

DAYOFYEAR returns the ordinal day of the year for a date, typically ranging from 1 through 365 or 366 in leap years.

Day-of-year analysis is useful for seasonal comparisons and tracking activity across a full calendar year.

Find the day number for each transaction date.

SQL
SELECT
    OrderDate,
    DAYOFYEAR(OrderDate) AS YearDay
FROM Orders;

DAYOFYEAR can support seasonal analysis, annual trend comparisons, forecasting, and operational monitoring.

  • DAYOFYEAR returns the position within the year.
  • Normal years contain 365 days.
  • Leap years contain 366 days.
  • It supports seasonal analysis.
  • Function syntax varies between databases.
What does DAYOFYEAR return?

It returns the ordinal position of a date within its year.

Why is DAYOFYEAR useful?

It can help compare activity by the same point in different years.

Have you finished this lesson?

Introduction to SQL – All Lessons