FUNCTION REFERENCE

years

Duration in fixed-length years, or a duration as a number of years.

Duration in fixed-length years, or a duration as a number of years.

Syntax

d = years(x)

Syntax

x = years(d)

A year is exactly 365.2425 days, so adding years(1) moves a date by

365 days, 5 hours, 49 minutes and 12 seconds.

Example

d = years(1)   % 1 yr

Example

t = datetime(2024, 2, 29) + years(1)   % 28-Feb-2025 05:49:12

Differences from MATLAB: There are no calendar years (calyears) yet.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.