ymd
Year, month and day of each date.
Category: Language Fundamentals > Data Types
Syntax
[y, m, d] = ymd(t)
Returns the year, month and day numbers of each element of t.
Description
The three outputs split a date into its calendar fields. The time of day is ignored. It is equivalent to calling year, month and day separately, but needs only one pass over the data.
Input arguments
t- A
datetimearray.
Output arguments
y, m, d- Double arrays, each the same size as
t.
Example
[y, m, d] = ymd(datetime(2024, 3, 15) + days(0:1))
Output
y = 1×2
2024 2024
m = 1×2
3 3
d = 1×2
15 16