This documentation is archived and is not being maintained.

DateTimeOffset::Subtract Method (TimeSpan)

Subtracts a specified time interval from the current DateTimeOffset object.

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

DateTimeOffset Subtract(
	TimeSpan value


Type: System::TimeSpan
The time interval to subtract.

Return Value

Type: System::DateTimeOffset
An object that is equal to the date and time represented by the current DateTimeOffset object, minus the time interval represented by value.


The resulting DateTimeOffset value is less than MinValue.


The resulting DateTimeOffset value is greater than MaxValue.

You can use the Subtract method to subtract more than one kind of time interval (days, hours, minutes, seconds, or milliseconds) in a single operation. Its behavior is identical to the Subtraction(DateTimeOffset, TimeSpan) method, which defines the subtraction operator. The DateTimeOffset structure also supports specialized addition methods (such as AddDays, AddHours, and AddMinutes) that allow you to perform subtraction by assigning a negative value to the method parameter.


This method returns a new DateTimeOffset object. It does not modify the value of the current object by adding timeSpan to its date and time.

The Subtract method does not affect the value of the DateTimeOffset object's Offset property. The returned DateTimeOffset object has the same offset as the original object.

Because the current DateTimeOffset object does not represent the date and time in a specific time zone, the Subtract(TimeSpan) method does not consider a particular time zone's adjustment rules when it performs the subtraction.

The following example illustrates subtraction that uses the Subtract method.

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

.NET Framework

Supported in: 4, 3.5 SP1, 3.0 SP1, 2.0 SP1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.