ymd - Year, month, and day numbers of datetime - MATLAB (original) (raw)

Year, month, and day numbers of datetime

Syntax

Description

[[y](#bufrvsq-1-y),[m](#bufrvsq-1-m),[d](#bufrvsq-1-d)] = ymd([t](#bufrvsq-1%5Fsep%5Fshared-t)) returns the year, month, and day numbers of the datetime values int as separate numeric arrays. The y,m, and d outputs are the same size ast, and contain integer values.

The ymd function is equivalent to calling theyear, month, and day functions on the same datetime array.

example

Examples

collapse all

t = datetime(2013,05,31):calmonths(3):datetime(2014,06,15)

t = 1×5 datetime 31-May-2013 31-Aug-2013 30-Nov-2013 28-Feb-2014 31-May-2014

y = 1×5

    2013        2013        2013        2014        2014

ymd returns the year, month, and day values in separate arrays.

Input Arguments

collapse all

Input date and time, specified as a datetime array.

Output Arguments

collapse all

ISO year numbers, returned as a scalar, vector, matrix, or multidimensional array of integer values. ISO year numbers include a year zero and represent years BCE using negative values. y is of type double and is the same size ast.

Month numbers, returned as a scalar, vector, matrix, or multidimensional array of integer values from 1 to 12. m is of typedouble and is the same size ast.

Day of month numbers, returned as a scalar, vector, matrix, or multidimensional array of integer values from 1 to 28, 29, 30, or 31, depending on the month and year. d is of typedouble and is the same size ast.

Extended Capabilities

expand all

Theymd function fully supports tall arrays. For more information, see Tall Arrays.

Version History

Introduced in R2014b