Date.AddYears

Date

Adds a specified number of years to a date value.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Date.AddYears(dateTime as any, numberOfYears as number) as any

Parameters

NameTypeRequiredDescription
dateTimeanyYesThe date, datetime, or datetimezone value to add years to.
numberOfYearsnumberYesThe number of years to add. Use negative values to subtract years.

Return Value

anyThe date resulting from adding the specified number of years to the input date.

Remarks

Date.AddYears adds or subtracts a whole number of years from a date, datetime, or datetimezone value. If the original date is February 29 and the target year is not a leap year, the result is clamped to February 28.

Examples

Example 1: Calculate employee tenure milestones

Table.AddColumn(
    Table.SelectColumns(
        Table.FirstN(Employees, 4),
        {"FullName", "HireDate"}
    ),
    "FiveYearAnniversary", each Date.AddYears([HireDate], 5), type date
)
Result
FullName
HireDate
FiveYearAnniversary
1John Smith3/15/20213/15/2026
2Sara Johnson7/1/20197/1/2024
3Mike Davis1/10/20221/10/2027
4Emily Chen6/20/20236/20/2028

Example 2: Subtract years from a date

#table(
    type table [OriginalDate = date, TwoYearsAgo = date],
    {{#date(2024, 4, 1), Date.AddYears(#date(2024, 4, 1), -2)}}
)
Result
OriginalDate
TwoYearsAgo
14/1/20244/1/2022

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks