Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

DateTime.AddYears Method

Adds the specified number of years to the value of this instance.

[Visual Basic]
Public Function AddYears( _
   ByVal value As Integer _
) As DateTime
public DateTime AddYears(
 int value
public: DateTime AddYears(
 int value
public function AddYears(
   value : int
) : DateTime;


A number of years. The value parameter can be negative or positive.

Return Value

A DateTime whose value is the sum of the date and time represented by this instance and the number of years represented by value.


Exception Type Condition
ArgumentOutOfRangeException value or the resulting DateTime is less than MinValue or greater than MaxValue.


This method does not change the value of this DateTime. Instead, a new DateTime is returned whose value is the result of this operation.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

DateTime Structure | DateTime Members | System Namespace | Double

© 2018 Microsoft