Subtract Method (DateTime)
[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]
Subtracts the specified date and time from this instance.
Assembly: mscorlib (in mscorlib.dll)
- Type: System..::..DateTime
The date and time value to subtract.
Return ValueType: System..::..TimeSpan
A time interval that is equal to the date and time represented by this instance minus the date and time represented by val.
If the date and time of the current instance is earlier than val, the method returns a TimeSpan object that represents a negative time span. That is, the value of all of its non-zero properties (such as Days or Ticks) is negative.
The method does not consider the value of the Kind property of the two DateTime values when performing the subtraction. Before subtracting DateTime objects, ensure that the objects represent times in the same time zone. Otherwise, the result will include the difference between time zones.
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see dd66cd4c-b087-415f-9c3e-94e3a1835f74.