All Products
Search
Document Center

MaxCompute:DAYOFYEAR

Last Updated:Mar 26, 2026

Returns the day of the year for a given date as an integer.

Syntax

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

Parameters

date: required. A date value of the DATETIME, TIMESTAMP, DATE, or STRING type. Accepted formats:

  • yyyy-mm-dd

  • yyyy-mm-dd hh:mi:ss

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

For STRING values, the input must include at least the yyyy-mm-dd part and must not contain extra characters.

Return value

Returns an INT value. Returns null if the input is null or the value is not one of the supported types or formats.

Examples

SELECT dayofyear('2016-04-09') AS day_of_year;

Output:

day_of_year
100

April 9 is the 100th day of 2016.

Related functions

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