
'Declaration Public Structure TdPeriodDate Inherits System.ValueType Implements System.Data.SqlTypes.INullable, System.IComparable, System.IComparable(Of TdPeriodDate), System.IConvertible, System.IEquatable(Of TdPeriodDate), System.IFormattable, System.Xml.Serialization.IXmlSerializable
'Usage Dim instance As TdPeriodDate
public struct TdPeriodDate : System.ValueType, System.Data.SqlTypes.INullable, System.IComparable, System.IComparable<TdPeriodDate>, System.IConvertible, System.IEquatable<TdPeriodDate>, System.IFormattable, System.Xml.Serialization.IXmlSerializable
public value class TdPeriodDate : public System.ValueType, System.Data.SqlTypes.INullable, System.IComparable, System.IComparable<TdPeriodDate>, System.IConvertible, System.IEquatable<TdPeriodDate>, System.IFormattable, System.Xml.Serialization.IXmlSerializable
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
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(); }
System.Object
System.ValueType
Teradata.Client.Provider.TdPeriodDate
Target Platforms: Windows 8.1, Windows 10, Windows Server 2012 R2, Windows Server 2016, Windows Server 2019
TdPeriodDate Members
Teradata.Client.Provider Namespace
TdDate Structure
TdDate Structure
Provider Specific Types: Period Type Overview