
'Declaration Public Structure TdPeriodTimestamp Inherits System.ValueType Implements System.Data.SqlTypes.INullable, System.IComparable, System.IComparable(Of TdPeriodTimestamp), System.IConvertible, System.IEquatable(Of TdPeriodTimestamp), System.IFormattable, System.Xml.Serialization.IXmlSerializable
'Usage Dim instance As TdPeriodTimestamp
public struct TdPeriodTimestamp : System.ValueType, System.Data.SqlTypes.INullable, System.IComparable, System.IComparable<TdPeriodTimestamp>, System.IConvertible, System.IEquatable<TdPeriodTimestamp>, System.IFormattable, System.Xml.Serialization.IXmlSerializable
public value class TdPeriodTimestamp : public System.ValueType, System.Data.SqlTypes.INullable, System.IComparable, System.IComparable<TdPeriodTimestamp>, System.IConvertible, System.IEquatable<TdPeriodTimestamp>, System.IFormattable, System.Xml.Serialization.IXmlSerializable
The Advanced SQL Engine introduced the Period type in release 13.00.00.00. Unfortunately, the .Net Framework does not contain a system type that corresponds to the Teradata Period(Timestamp) type. Therefore, the Teradata provider exposes the TdPeriodTimestamp type which enables an application to work with data of type Period(Timestamp).
Similar to TdTimestamp, TdPeriodTimestamp supports a scale for the sub-seconds. The scale ranges from 0 to 6 and must be the same for both the beginning and ending bounds.
A period is an anchored duration. It represents a set of contiguous time granules within that duration. In the case of TdPeriodTimestamp, the granularity of the time can range from 10^-6 (.000006 second) to 10^0 (1 second). The representation of a period is both inclusive and exclusive. It is inclusive in that the duration of the period begins from the beginning bound up to, but not including (excluding), the ending bound. For example suppose a TdPeriodTimestamp contains the period of:
(2008-10-31 13:12:21.05, 2008-12-01 20:43:27.98)
The period will include "2008-10-31 13:12:21.05" and not "2008-12-01 20:43:27.98". It has a duration of 32.07:31:06.93 (32 days, 7 hours, 31 minutes, 6 seconds, 980000 microseconds). The time element "2008-11-30 15:21:43" is included in the period.
The components of a period consists of the following:
A TdPeriodTimestamp 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); TdDataReader dr = null; Int32 i = 0; TdPeriodTimestamp detention; Try { dr = cmd.ExecuteReader(); If (false == dr.Read()) { return; } // Retrieving the Period detention = dr.GetTdPeriodTimestamp(0); } finally { if (dr != null) { dr.Close(); } } // An additional 1 day, 4 hours will be added to ending bound. // Specifying a TimeSpan of 1 hour System.TimeSpan extraDentention = new TimeSpan(1, 4, 0, 0); // Getting the ending bound of the period and // adding 1 hour to it detention = new TdPeriodTime(detention.Begin, detention.End + extraDetention); cmd.Parameters.Clear(); cmd.CommandText = "UPDATE classDetention " + "SET timePeriod = ? " + "WHERE StudentId = ?"; cmd.Parameters.Add(null, TdType.PeriodTimestamp, 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.TdPeriodTimestamp
Target Platforms: Windows 8.1, Windows 10, Windows Server 2012 R2, Windows Server 2016, Windows Server 2019
TdPeriodTimestamp Members
Teradata.Client.Provider Namespace
TdTimestamp Structure
Provider Specific Types: Period Type Overview