TimeSpan::Subtraction Operator (TimeSpan, TimeSpan)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.


Subtracts a specified TimeSpan from another specified TimeSpan.

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

static TimeSpan operator -(
	TimeSpan t1,
	TimeSpan t2


Type: System::TimeSpan

The minuend.

Type: System::TimeSpan

The subtrahend.

Return Value

Type: System::TimeSpan

An object whose value is the result of the value of t1 minus the value of t2.

Exception Condition

The return value is less than TimeSpan::MinValue or greater than TimeSpan::MaxValue.

The following example uses the TimeSpan subtraction operator to calculate the total length of the weekly work day. It also uses the TimeSpan addition operator to compute the total time of the daily breaks before using it in a subtraction operation to compute the total actual daily working time.

No code example is currently available or this language may not be supported.

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