System.DateTime.op_Subtraction Method

Subtracts a specified time interval from a specified date and time and returns a new date and time.

Syntax

public static DateTime operator- (DateTime d, TimeSpan t)

Parameters

d
The date and time value to subtract from.
t
The time interval to subtract.

Returns

An object whose value is the value of d minus the value of t.

Exceptions

TypeReason
ArgumentOutOfRangeExceptionThe resulting date and time is less than DateTime.MinValue or greater than DateTime.MaxValue.

Remarks

This method subtracts the ticks value of t from the ticks value of d.

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0