datetime

Methods

Method Reference: datetime.ymd

datetime: [Y, M, D] = ymd (T)

Year, Month, and Day components of datetime array.

[Y, M, D] = ymd (T) returns the year, month, and day components of the corresponding datetime values in T as separate numeric arrays. Y, M, D contain integer values and have the same size as T. Not-A-Time (NaT) values in T are returned as NaN in the output arrays.

Source Code: datetime

ymd splits each datetime into its year, month and day as three separate numeric outputs.

 t = datetime (2024, 3, 9, 14, 30, 45)
t =
  datetime

   09-Mar-2024 14:30:45
 [y, m, d] = ymd (t);
 [y, m, d]
ans =

   2024      3      9