Send feedback on this topic.
Teradata.Client.Provider
TdPeriodDate Structure
Members  Example 



Teradata.Client.Provider Namespace : TdPeriodDate Structure
TdPeriodDate is a .Net Data Provider for Teradata specific type that represents a duration of time that is bound by beginning and ending dates. The dates are based on the Gregorian calendar.
Object Model
TdPeriodDate StructureTdPeriodDate StructureTdDate StructureTdDate StructureTdPeriodDate StructureTdIntervalDayToSecond StructureTdIntervalYearToMonth StructureTdDate StructureTdPeriodDate StructureTdPeriodDate StructureTdPeriodDate StructureTdPeriodDate StructureTdPeriodDate Structure
Syntax
Remarks

The Advanced SQL Engine introduced Period types in release 13.00.00.00. Unfortunately, .NET does not have system types that correspond to any of the the SQL Period types. Therefore, the Data Provider exposes a corresponding provider specific type for each of the period types supported by the SQL Engine.

For the Teradata Period type Period(Date) the provider specific type is TdPeriodDate. This type enables an application to work with data that contain a period of type date.

A period is an anchored duration. It represents a set of contiguous time granules within that duration. In the case of TdPeriodDate, the granularity of the time is represented by a day. The representation of a period is both inclusive and exclusive. It is inclusive in that the duration of the period begins from lower bound up to, but not including (excluding), the ending bound. For example, suppose a TdPeriodDate contains the period of:

   (2007-12-25, 2008-01-01)

The period will include "2007-12-25" and not "2008-01-01". It extends for 7 days.

The components of a period consists of the following:

A TdPeriodDate can also be specified as an In, Out, or InOut parameter to a Stored Procedure. The data will be returned to an application using either the TdParameter.ProviderSpecificValue or TdParameter.Value property. Retrieving the parameter using TdParameter.ProviderSpecificValue, will return the data using the Period structure. When TdParameter.Value is used, the data is returned as a String (this is the corresponding .Net type).

Example
The following is an example on retrieving a TdPeriodDate, modify the period, and then updating the period.
Public void PeriodDateExample(TdCommand cmd, String studentId)
{
   cmd.Parameter.Clear();
             
   cmd.CommandText = "SELECT timePeriod  " +
                   "FROM ClassDetention " +
                   "WHERE StudentId = ?";
             
   cmd.CommandType = CommandType.Text;
             
   // creating the parameter
   cmd.Parameters.Add(null, TdType.Varchar, 9,
      System.Data.ParameterDirection.Input, true, 0, 0, null,    
      System.Data.DataRowVersion.Default, studentId);
             
   TdPeriodDate detention;
             
   using (TdDataReader dr = cmd.ExecuteReader())
   {
      If (false == dr.Read())
      {
	       return;
      }
   
      // Retrieving the Period
      detention = dr.GetTdPeriodDate(0);
   }
             
   // An additional 5 days will be added to ending bound.
             
   // Specifying a TimeSpan of 5 days
   System.TimeSpan fiveExtraDays = new TimeSpan(5, 0, 0, 0);
             
   // Getting the ending bound of the period and
   // adding 5 days to it
   TdDate endOfDetention = detention.End + fiveExtraDays;
             
   detention = new TdPeriodDate(detention.Begin, endOfDetention);    
             
   cmd.Parameters.Clear();
             
   cmd.CommandText = "UPDATE classDetention " +
                        "SET timePeriod = ? " +
                        "WHERE StudentId = ?";
             
   cmd.Parameters.Add(null, TdType.PeriodDate, 0,
         System.Data.ParameterDirection.Input, true, 0, 0, null,    
         System.Data.DataRowVersion.Default, detention);
             
   cmd.Parameters.Add(null, TdType.Varchar, 9,
         System.Data.ParameterDirection.Input, true, 0, 0, null,    
         System.Data.DataRowVersion.Default, studentId);
             
   cmd.ExecuteNonQuery();
}
Inheritance Hierarchy

System.Object
   System.ValueType
      Teradata.Client.Provider.TdPeriodDate

Requirements

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

See Also

Reference

TdPeriodDate Members
Teradata.Client.Provider Namespace
TdDate Structure
TdDate Structure
Provider Specific Types: Period Type Overview