System.DateTime.Add Method

Returns a new DateTime that adds the value of the specified TimeSpan to the value of this instance.


public DateTime Add (TimeSpan value)


A positive or negative time interval.


An object whose value is the sum of the date and time represented by this instance and the time interval represented by value.


ArgumentOutOfRangeExceptionThe resulting DateTime is less than DateTime.MinValue or greater than DateTime.MaxValue.


You can use the DateTime.Add(TimeSpan) method to add more than one kind of time interval (days, hours, minutes, seconds, or milliseconds) in a single operation. This method's behavior is identical to that of the addition operator. The DateTime structure also supports specialized addition methods (such as DateTime.AddDays(double), DateTime.AddHours(double), and DateTime.AddMinutes(double)) for each time interval.

The DateTime.Add(TimeSpan) method takes into account leap years and the number of days in a month when performing date arithmetic.

This method does not change the value of this DateTime. Instead, it returns a new DateTime whose value is the result of this operation. The DateTime.Kind property of the new DateTime instance is the same as that of the current instance.


Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0,,