Date.AddYears
DateAdds a specified number of years to a date value.
Syntax
Date.AddYears(dateTime as any, numberOfYears as number) as anyParameters
| Name | Type | Required | Description |
|---|---|---|---|
dateTime | any | Yes | The date, datetime, or datetimezone value to add years to. |
numberOfYears | number | Yes | The number of years to add. Use negative values to subtract years. |
Return Value
any — The 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 | |
|---|---|---|---|
| 1 | John Smith | 3/15/2021 | 3/15/2026 |
| 2 | Sara Johnson | 7/1/2019 | 7/1/2024 |
| 3 | Mike Davis | 1/10/2022 | 1/10/2027 |
| 4 | Emily Chen | 6/20/2023 | 6/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 | |
|---|---|---|
| 1 | 4/1/2024 | 4/1/2022 |
Compatibility
✓ Power BI Desktop✓ Power BI Service✓ Excel Desktop✓ Excel Online✓ Dataflows✓ Fabric Notebooks