
'Declaration Public Structure TdIntervalDayToHour Inherits System.ValueType Implements System.Data.SqlTypes.INullable, System.IComparable, System.IComparable(Of TdIntervalDayToHour), System.IConvertible, System.IEquatable(Of TdIntervalDayToHour), System.IFormattable, System.Xml.Serialization.IXmlSerializable
'Usage Dim instance As TdIntervalDayToHour
public struct TdIntervalDayToHour : System.ValueType, System.Data.SqlTypes.INullable, System.IComparable, System.IComparable<TdIntervalDayToHour>, System.IConvertible, System.IEquatable<TdIntervalDayToHour>, System.IFormattable, System.Xml.Serialization.IXmlSerializable
public value class TdIntervalDayToHour : public System.ValueType, System.Data.SqlTypes.INullable, System.IComparable, System.IComparable<TdIntervalDayToHour>, System.IConvertible, System.IEquatable<TdIntervalDayToHour>, System.IFormattable, System.Xml.Serialization.IXmlSerializable
TdIntervalDayToHour is a .NET Data Provider for Teradata specific type, designed to support a SQL Interval Day To Hour data type.
The TdIntervalDayToHour supports the Teradata Interval Day (precision) To Hour data type where precision indicates the number of digits in the day (from 1 - 4).
The interval value must be specified in the following format :
[sign][days][space character][hh]
Below is the description of each format item.
Format Item | Description |
---|---|
sign | Optional - . Defaults as space character (+). |
days | Required number of days (one to four digits in length). |
hh | Required number of hours from 00 - 23. |
.NET does not have a system type that directly corresponds to the SQL Interval Day To Hour data type. The .NET Data Provider for Teradata Version 13.0 and prior versions map Interval Day To Hour to System.String. With version 13.1 of the provider, TdIntervalDayToHour is available to retrieve and manipulate data of type Interval Day To Hour.
The range of values for each TdInterval precision is as follows:
Type and Precision | Minimum | Maximum |
---|---|---|
TdIntervalDayToHour(1) |
-'9 23' |
'9 23' |
TdIntervalDayToHour(2) |
-'99 23' |
'99 23' |
TdIntervalDayToHour(3) |
-'999 23' |
'999 23' |
TdIntervalDayToHour(4) |
-'9999 23' |
'9999 23' |
TdIntervalDayToHour also supports TdIntervalDayToHour.Null. This is a very important feature. An application is no longer required to call TdDataReader.IsDBNull before invoking the corresponding TdDataReader "Get" method. This will improve overall performance.
A TdIntervalDayToHour structure allows arithmetic, comparision and conversion operations to be performed.
A TdIntervalDayToHour may also be specified as an in, out, or in/out parameter to a stored procedure. In order to maintain backward compatibility with previous versions of the provider (release 13.0 and prior), a Connection String Attribute TdConnectionStringBuilder.EnableTdIntervals has been added. When the EnableTdIntervals attribute is true
, TdParameter.ProviderSpecificValue will return the data as the provider specific type of TdIntervalDayToHour. When EnableTdIntervals is false
, TdParameter.ProviderSpecificValue will return the data as a .NET Framework Library data type of String.
The TdParameter.Value will also return the .NET Framework Library data type of System.String when EnableTdIntervals is false
to maintain backward compatibility. The TdParameter.Value will return a .NET Framework data type of TimeSpan when EnableTdIntervals is true
.
For more information on the SQL Interval Day To Hour data type please see the 'SQL Data Types and Literals'.
The following example shows how to retrieve a TdIntervalDayToHour, modify the interval, and then update the table.
Public void IntervalExample(TdCommand cmd, String model) { cmd.Parameters.Clear(); cmd.CommandText = "SELECT StartDate, LeaseReturn, DelayPeriod " + "FROM AutoLeases " + "WHERE Model = ?"; cmd.CommandType = CommandType.Text; cmd.Parameters.Add(null, TdType.VarChar, 10, ParameterDirection.Input, true, 0, 0, null, DataRowVersion.Default, model); Int32 row = 0; TdDate [] startDate; TdTimestamp [] leaseReturn; TdIntervalDayToHour [] leaseLen; using (TdDataReader dr = cmd.ExecuteReader()) { startDate = new TdDate[dr.RecordsReturned]; leaseReturn = new TdTimestamp[dr.RecordsReturned]; leaseLen = new TdIntervalDayToHour [dr.RecordsReturned]; // Specifying an interval of 7 days, 1 hour with a day precision of 4 TdIntervalDayToHour leaseReturnExtension = new TdIntervalDayToHour(7, 1, 4); while (dr.Read()) { // Retrieving the dates startDate[row] = dr.GetTdDate(0); leaseReturn[row] = dr.GetTimestamp(1); leaseLen[row] = dr.GetTdIntervalDayToHour(2); // Adding extension to the lease return leaseReturn[row] = leaseReturn[row] + leaseReturnExtension; // Adding extension to the lease length; leaseLen[row] = leaseLen[row] + leaseReturnExtension; row++; } } cmd.Parameters.Clear(); cmd.CommandText = "UPDATE AutoLeases " + "SET LeaseReturn = ?, LeaseLen = ? " + "WHERE Model = ?"; cmd.Parameters.Add(null, TdType.Timestamp, 0, ParameterDirection.Input, true, 0, 0, null, DataRowVersion.Default, null); cmd.Parameters.Add(null, TdType.IntervalDayToHour, 0, ParameterDirection.Input, true, 0, 0, null, DataRowVersion.Default, null); cmd.Parameters.Add(null, TdType.VarChar, 9, ParameterDirection.Input, true, 0, 0, null, DataRowVersion.Default, model); row--; while(row >= 0) { cmd.Parameters[0].Value = leaseReturn[row]; cmd.Parameters[1].Value = leaseLen[row]; cmd.Parameters[2].Value = model; cmd.ExecuteNonQuery(); row--; } }
System.Object
System.ValueType
Teradata.Client.Provider.TdIntervalDayToHour
Target Platforms: Windows 8.1, Windows 10, Windows Server 2012 R2, Windows Server 2016, Windows Server 2019
TdIntervalDayToHour Members
Teradata.Client.Provider Namespace
Enabling Provider Specific Types
EnableTdIntervals Property
Interval Connection String Attribute
Provider Specific Type: Interval Type Overview