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.Add Method

Adds the value of the specified TimeSpan to the value of this instance.

[Visual Basic]
Public Function Add( _
   ByVal value As TimeSpan _
) As DateTime
public DateTime Add(
 TimeSpan value
public: DateTime Add(
 TimeSpan value
public function Add(
   value : TimeSpan
) : DateTime;


A TimeSpan that contains the interval to add.

Return Value

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


Exception Type Condition
ArgumentOutOfRangeException 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.


[Visual Basic, C#, C++] The following sample demonstrates the Add method. It calculates the day of the week that is 36 days (864 hours) from this moment.

[Visual Basic] 
' Calculate what day of the week is 36 days from this instant.
Dim today As System.DateTime
Dim duration As System.TimeSpan
Dim answer As System.DateTime

today = System.DateTime.Now
duration = New System.TimeSpan(36, 0, 0, 0)
answer = today.Add(duration)

System.Console.WriteLine("{0:dddd}", answer)

// Calculate what day of the week is 36 days from this instant.
System.DateTime today = System.DateTime.Now;
System.TimeSpan duration = new System.TimeSpan(36, 0, 0, 0);
System.DateTime answer = today.Add(duration);
System.Console.WriteLine("{0:dddd}", answer);

// Calculate what day of the week is 36 days from this instant.
System::DateTime today = System::DateTime::Now;
System::TimeSpan duration(36, 0, 0, 0);
System::DateTime answer = today.Add(duration);
System::Console::WriteLine(S" {0:dddd}", __box(answer));

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


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 | TimeSpan | TimeSpan.Add

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2014 Microsoft