DateTimeOffset::Subtract Method (TimeSpan)
Subtracts a specified time interval from the current DateTimeOffset object.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- value
- Type: System::TimeSpan
The time interval to subtract.
Return Value
Type: System::DateTimeOffsetAn object that is equal to the date and time represented by the current DateTimeOffset object, minus the time interval represented by value.
| Exception | Condition |
|---|---|
| ArgumentOutOfRangeException | The resulting DateTimeOffset value is less than MinValue. -or- 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.
Note |
|---|
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.
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.
Note