Send feedback on this topic.
Teradata.Client.Provider
Subtract(TimeSpan) Method



Teradata.Client.Provider Namespace > TdPeriodDate Structure > Subtract Method : Subtract(TimeSpan) Method
The TimeSpan that will be subtracted.
The specified TimeSpan will be subtracted from this instance of TdPeriodDate.
Syntax
'Declaration
 
Public Overloads Function Subtract( _
   ByVal timeSpan As TimeSpan _
) As TdPeriodDate
'Usage
 
Dim instance As TdPeriodDate
Dim timeSpan As TimeSpan
Dim value As TdPeriodDate
 
value = instance.Subtract(timeSpan)
public TdPeriodDate Subtract( 
   TimeSpan timeSpan
)
public:
TdPeriodDate Subtract( 
   TimeSpan timeSpan
) 

Parameters

timeSpan
The TimeSpan that will be subtracted.

Return Value

A TdPeriodDate is returned that is the result of the TimeSpan subtracted from this instance of TdPeriodDate.
Exceptions
ExceptionDescription
The result could not be represented as a TdPeriodDate.
The TdPeriodDate beginning bound is greater or equal to the ending bound of the period.
Remarks

The only component of the TimeSpan object that will be considered is the day component. When this operation is performed, the day component of the TimeSpan is subtracted from the this instance of TdPeriodDate. For example, if the period is ('2007-10-04', '2007-11-01') and TimeSpan is "0.02:00:00.00" (0 days, 2 hours) the subtract operation will result in ('2007-10-04', '2007-11-01').

There is an exception to this behavior. The Teradata Database contains the reserved word UNTIL_CHANGED. This reserved word is used as the end bound of a period and signifies that the period goes on forever or "until it is changed." In the Teradata Database, UNTIL_CHANGED is equivalent to the date 9999-12-31 for a period of type date.

When the end bound of a period is UNTIL_CHANGED or 9999-12-31, arithmetic operations performed on this period only affects the beginning bound. This is the behavior of the Teradata Database and the Teradata provider.

The following are examples of the result of subtraction a TimeSpan from a period:

Arithmetic Operation Result
(2008-12-20, 2009-06-30) - 2.02:01:30 (2 days, 2 hours, 1 minute, 30 seconds) (2008-12-18, 2009-06-28)
(8901-02-03, 9999-12-31) - 10.21:00:01.002 (8901-01-14, 9999-12-31)
(7865-10-05, 8010-09-30) - 0.47:60:21 (0 days, 47 hours, 60 minutes, 21 seconds)** (7895-10-03, 8010-09-28)
(9999-12-30, 9999-12-31) - 1.00:00:00 (9999-12-29, 9999-12-31)

**The number of days will be calculated from the components that were specified when TimeSpan was initialized. Therefore, if a TimeSpan was initialized as new TimeSpan(47, 60, 20) (47 hours, 60 minutes, 20 seconds), the number of days that will be subtracted from TdPeriodDate will be 2.

Refer to Period Arithmetic for additional information.

Requirements

Target Platforms: Windows 7, Windows 8, Windows 8.1, Windows 10, Windows Server 2008, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2

See Also

Reference

TdPeriodDate Structure
TdPeriodDate Members
Overload List