All Products
Search
Document Center

MaxCompute:DAYOFWEEK

Last Updated:Mar 26, 2026

Returns the day of the week for a date value as an integer from 1 (Sunday) to 7 (Saturday).

Syntax

int dayofweek(datetime|timestamp|date|string <date>)

Parameters

date: Required. A date value of the DATETIME, TIMESTAMP, DATE, or STRING type. The STRING value must include at least the yyyy-mm-dd part and must not contain extra characters. Accepted formats:

  • yyyy-mm-dd

  • yyyy-mm-dd hh:mi:ss

  • yyyy-mm-dd hh:mi:ss.ff3

Return value

Returns an INT value from 1 to 7. Returns null if the input is null, not one of the supported types, or does not match a supported format.

Return valueDay
1Sunday
2Monday
3Tuesday
4Wednesday
5Thursday
6Friday
7Saturday

Examples

-- Returns 5 (Thursday)
SELECT dayofweek('2009-07-30');
-- Output: 5

Related functions

DAYOFWEEK is a date function. For more information about functions related to date computing and conversion, see Date functions.