Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

ymd

Year, month, and day numbers of datetime

Syntax

[y,m,d] = ymd(t)

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 array
   31-May-2013   31-Aug-2013   30-Nov-2013   28-Feb-2014   31-May-2014

[y,m,d] = ymd(t)
y = 

        2013        2013        2013        2014        2014

m = 

     5     8    11     2     5

d = 

    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.

Extended Capabilities

See Also

| | | | |

Introduced in R2014b

Was this topic helpful?