All Products
Search
Document Center

MaxCompute:DAYOFYEAR

Last Updated:Jul 24, 2023

Returns the sequence number of the day in the year.

Syntax

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

Parameters

date: required. A date value of the DATETIME, TIMESTAMP, DATE, or STRING type. The input value is in the yyyy-mm-dd, yyyy-mm-dd hh:mi:ss, or yyyy-mm-dd hh:mi:ss.ff3 format. If the value is of the STRING type, the value must include at least the yyyy-mm-dd part and must not contain extra strings.

Return value

A value of the INT type is returned. The return value varies based on the following rules:

  • If the value of date is not of the DATETIME, TIMESTAMP, DATE, or STRING type or the format does not meet the requirements, null is returned.

  • If the value of date is null, null is returned.

Examples

-- The value 100 is returned. 
SELECT dayofyear('2016-04-09');

Related functions

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