Beginner

277. DAYOFWEEK Function

Learn how to determine the weekday associated with a date.

📘 Lesson 277 of 728 ⏱ 9 min 🎯 Intermediate

A DAYOFWEEK function or equivalent date operation returns an indicator representing the day of the week for a given date. The numbering convention depends on the database system.

Weekday analysis helps identify business patterns between weekdays and weekends.

Determine the weekday associated with each order date.

SQL
SELECT
    OrderDate,
    DAYOFWEEK(OrderDate) AS WeekDay
FROM Orders;

DAYOFWEEK is useful for retail analysis, staffing, customer activity, operational reporting, and weekly trend analysis.

  • DAYOFWEEK identifies the weekday.
  • Numbering conventions vary.
  • It can separate weekdays and weekends.
  • It supports weekly trend analysis.
  • Database-specific alternatives may be required.
What does DAYOFWEEK do?

It returns an indicator representing the weekday for a specified date.

Why should you check database documentation?

Different databases may number weekdays differently.

Have you finished this lesson?

Introduction to SQL – All Lessons