Tabular IQ
Back to Function Index

DAYOFWEEK()

Overview

DAYOFWEEK() returns a numeric representation of the day of the week for a given date, where 1 represents Sunday, 2 represents Monday, and so on through 7 for Saturday. This function is useful for date-based calculations, filtering, and reporting where you need to work with numeric day values.

Function Format

DAYOFWEEK(date)

Return Value

DAYOFWEEK() returns an integer from 1 to 7, or 0 for NULL dates

Examples


DAYOFWEEK(DATE("12/25/2025"))           = 5  (Thursday)
DAYOFWEEK(DATE(2025, 12, 25))          = 5  (Thursday)
DAYOFWEEK(DATE("2025-01-01"))          = 4  (Wednesday)
DAYOFWEEK(DATE("2025-02-28"))          = 6  (Friday)
DAYOFWEEK(DATE("2025-03-31"))          = 2  (Monday)
DAYOFWEEK(CURDATE())                   = 4  (Wednesday, if run on March 19, 2025)
DAYOFWEEK(NULL)                        = 0

Notes

  • The function returns an integer from 1 to 7, where:
    • 1 = Sunday
    • 2 = Monday
    • 3 = Tuesday
    • 4 = Wednesday
    • 5 = Thursday
    • 6 = Friday
    • 7 = Saturday
  • If the input date is NULL, the function returns 0.
  • Common use cases include:
    • Weekend vs weekday filtering
    • Business day calculations
    • Schedule and calendar applications
    • Date-based reporting and analytics
  • The function can be used with any valid date expression, including:
    • Date literals
    • Date columns
    • Date functions
    • Date arithmetic expressions
  • This function is equivalent to EXTRACT(DOW FROM date) + 1 in some database systems.
  • Note that this function uses Sunday as the first day of the week (1), which differs from some other systems that use Monday as the first day.

See Also