DateTime.Subtract Method (DateTime)
Subtracts the specified date and time from this instance.
Assembly: mscorlib (in mscorlib.dll)
The Subtract(TimeSpan) method. To subtract a particular time interval from the current instance, call the method that adds that time interval to the current date, and supply a negative value as the method argument. For example, to subtract two months from the current date, call the AddMonths(Int32) method with a value of -2.method determines the difference between two dates. To subtract a time interval from the current instance, call the
If the date and time of the current instance is earlier than value, 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.
TheKind 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.method does not consider the value of the
The DateTimeOffset.Subtract(DateTimeOffset) method does consider the difference between time zones when performing the subtraction.
Available since 8
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Available since 8.1