DateTime.Addition Operator (DateTime, TimeSpan)


Adds a specified time interval to a specified date and time, yielding a new date and time.

Namespace:   System
Assembly:  mscorlib (in mscorlib.dll)

Public Shared Operator + (
	d As Date,
	t As TimeSpan
) As Date


Type: System.DateTime

The date and time value to add.

Type: System.TimeSpan

The time interval to add.

Return Value

Type: System.DateTime

An object that is the sum of the values of d and t.

Exception Condition

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

The following example demonstrates the addition operator.

Dim dTime As Date = #8/5/1980#

' tSpan is 17 days, 4 hours, 2 minutes and 1 second.
Dim tSpan As New TimeSpan(17, 4, 2, 1)

Dim result1, result2 As Date

' Result gets 8/22/1980 4:02:01 AM.
result1 = Date.op_Addition(dTime, tSpan)

result2 = dTime + tSpan 

Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top