y = year(t)
| Parameter | Description |
|---|---|
| inputs | datetime values, serial date numbers, or date-compatible input. |
| Parameter | Description |
|---|---|
| output | A double array of calendar years. |
Extract year numbers from date and time values.
year uses datevec for numeric date inputs and the Year dependent property for datetime inputs.
Array-valued inputs keep their data shape when the operation supports arrays. Scalar operands are expanded where the implementation defines scalar expansion.
t = datetime(2024, [1 12], [1 31])
year(t)
| Version | Description |
|---|---|
| 2.0.0 | initial version |