year
Extract year numbers from date and time values.
📝Syntax
y = year(t)
📥Input Arguments
Parameter Description
inputs datetime values, serial date numbers, or date-compatible input.
📤Output Arguments
Parameter Description
output A double array of calendar years.
📄Description

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.

💡Examples
Basic usage.
t = datetime(2024, [1 12], [1 31])
year(t)
🔗See Also
datetimeduration
🕔Version History
Version Description
2.0.0 initial version
Edit this page on GitHub