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



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

Parameters

timeSpan
The TimeSpan that will be added.

Return Value

A TdPeriodDate is returned that is the result of the TimeSpan added to 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 added to this instance of TdPeriodDate. The day component will be added to both the beginning and ending bounds. 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 add operation will result in a period of (2007-10-04, 2007-11-01).

There is an exception to this behavior. The Advanced SQL Engine contains the reserved word UNTIL_CHANGED. This reserved word can be used as the end bound of a period and signifies that the period goes on forever or "until it is changed." In the SQL Engine, 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 SQL Engine and the Data Provider.

The following are examples of the result of adding a TimeSpan to 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-22, 2009-07-02)
(8901-02-03, 9999-12-31) + 10.21:00:01.002 (8901-02-13, 9999-12-31)
(7865-10-05, 8010-09-30) + 0.47:60:21 (0 days, 47 hours, 60 minutes, 21 seconds)** (7895-10-07, 8010-10-02)
(9999-12-30, 9999-12-31) + 1.00:00:00 OverflowException thrown, Begin must be less than End.

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

Refer to Period Arithmetic for additional information.

Requirements

Target Platforms: Windows 8.1, Windows 10, Windows Server 2012 R2, Windows Server 2016, Windows Server 2019

See Also

Reference

TdPeriodDate Structure
TdPeriodDate Members
Overload List