ymd

Year, month, and day numbers of datetime

Description

example

[y,m,d] = ymd(t) returns the year, month, and day numbers of the datetime values in t as separate numeric arrays. The y, m, and d outputs are the same size as t, and contain integer values.

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

Examples

collapse all

t = datetime(2013,05,31):calmonths(3):datetime(2014,06,15)
t = 1x5 datetime
31-May-2013   31-Aug-2013   30-Nov-2013   28-Feb-2014   31-May-2014

[y,m,d] = ymd(t)
y = 1×5

2013        2013        2013        2014        2014

m = 1×5

5     8    11     2     5

d = 1×5

31    31    30    28    31

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 as t.

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

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 type double and is the same size as t.