The Schema collections return metadata for the Teradata Database objects. The notable metadata columns for the Period(Time With Time Zone) data type are:
Column Name | Description |
---|---|
COLUMN_TYPE or DATA_TYPE |
Set to PERIOD TIME WITH TIME ZONE. |
DATETIME_PRECISION | The number of digits in the fractional seconds component of the Period(Time With Time Zone) data type. The range of values are from Zero to Six. |
FORMAT | Teradata Database Format assigned to the Teradata Database object. |
PROVIDERDBTYPE | Set to TdType.PeriodTimeWithTimeZone. |
The TdDataReader.SchemaTable returns result set metadata. The notable metadata columns for the Period(Time With Time Zone) data type are:
Column Name | Description |
---|---|
ColumnSize | The maximum length in Characters. |
NumericScale | The number of digits in the fractional seconds component of the Period(Time With Time Zone) data type. The range of values are from Zero to Six. |
DataType | System.Type object for the System.String structure. |
ProviderType | Set to TdType.PeriodTimeWithTimeZone. |
Format | Teradata Database Format assigned to the Teradata Database object. |
ProviderSpecificDataType | System.Type object for the TdPeriodTimeWithTimeZone structure. |
The following example shows how to configure a Period(Time With Time Zone) parameter using DbType type declaration and a Base Class Library (BCL) value.
![]() |
---|
The Data Provider sends a VarChar data type to the Teradata Database when TdParameter.DbType is set to DbType.String. The Teradata Database will perform an implicit conversion to the Period(Time With Time Zone) data type when required. The Teradata Database SQL Functions, Operators, Expressions and Predicates manual documents all implicit and explicit Data Type conversions. |
C# |
Copy Code
|
---|---|
TdParameter deliveryPeriod = new TdParameter(); deliveryPeriod.DbType = DbType.String; deliveryPeriod.Value = "(02:54:56.49-11:00, 12:31:47.84-11:00)"; |
The following example shows how to configure a Period(Time With Time Zone) parameter using TdType type declaration and a Provider Specific value. The TdParameter.Scale property reflects the maximum number of digits for the Fractional Second component and it must be equal to or less than the target Teradata Database object (i.e. Column, Expression, Stored Procedure Parameters and etc.) declaration. The range of values are from Zero to Six. It is recommend to always set TdParameter.Scale property, however the Data Provider will utilize TdPeriodTimeWithTimeZone.Scale property value when the TdParameter.Scale, TdParameter.Precision and TdParameter.Size properties are set to zero. .NET Applications can retrieve metadata from the Schema Collections or the Schema Table and apply the metadata to the TdParameter object.
C# |
Copy Code
|
---|---|
TdParameter deliveryPeriod = new TdParameter(); deliveryPeriod.TdType = TdType.PeriodTimeWithTimeZone; // Maximum number of digits for the Fractional Second component. deliveryPeriod.Scale = 6; // The Time Zone defaults to local Time Zone. deliveryPeriod.ProviderSpecificValue = new TdPeriodTimeWithTimeZone(new TdTimeWithTimeZone(10, 15, 25, 123), new TdTimeWithTimeZone(15, 0, 0, 0)); |
The syntax for the Period(Time With Time Zone) Literal is PERIOD'(hh:mi:ss.ffffffSIGNhh:mi, hh:mi:ss.ffffffSIGNhh:mi)'. Period(Time With Time Zone) literals consist of the word PERIOD followed by character string literal representation of a beginning and ending bounds. The fractional seconds can vary from zero to six characters.
![]() |
---|
We recommend to always use Parameters in order to take advantage of the Teradata Database Request Cache. |
The following example shows a Period(Time With Time Zone) Literal embedded in the command Text.
C# |
Copy Code
|
---|---|
using (TdConnection cn = new TdConnection("data source=x;UserId=y;Password=z;")) { cn.Open(); TdCommand cmd = cn.CreateCommand(); cmd.CommandText = "INSERT INTO Policy (PolicyId, Validity) VALUES (2001, PERIOD'(08:00:00.000-08:00, 17:00:00.000-08:00)')"; cmd.ExecuteNonQuery(); } |
The following methods and properties return the column or parameter value as a System.String structure.
The following methods and properties return the column or parameter value as a TdPeriodTimeWithTimeZone structure.
C# |
Copy Code
|
---|---|
using (TdConnection cn = new TdConnection("data source=DS1;UserId=Joe;Password=XY;")) { cn.Open(); TdCommand cmd = cn.CreateCommand(); cmd.CommandText = "SELECT PolicyId, Validity from Policy where Validity > ?"; cmd.Parameters.Add("Validity", TdType.PeriodTimeWithTimeZone); cmd.Parameters[0].Scale = 6; // Time Zone defaults to Local Time Zone. cmd.Parameters[0].Value = new TdPeriodTimeWithTimeZone(new TdTimeWithTimeZone(8, 0, 0), new TdTimeWithTimeZone(17, 0, 0) ); using (TdDataReader reader = cmd.ExecuteReader()) { if (reader.HasRows) { while (reader.Read()) { Console.WriteLine("[String] Policy Validity = {0}", reader.GetString(1)); Console.WriteLine("[TdPeriodTimeWithTimeZone] Policy Validity = {0}", reader.GetTdPeriodTimeWithTimeZone(1).ToString()); } } } } /* Output: [String] Policy Validity = (09:30:00.000-08:00, 16:30:00.000-08:00) [TdPeriodTimeWithTimeZone] Policy Validity = (09:30:00.000-08:00:, 16:30:00.000-08:00) */ |
Accessor Methods for Retrieving Data
Configuring Parameters and Parameter Data Types