The Schema collections return metadata for the Advanced SQL Engine objects. The notable metadata columns for the Interval Day-to-Second data type are:
Column Name | Description |
---|---|
COLUMN_TYPE or DATA_TYPE |
Set to INTERVAL DAY TO SECOND. |
FORMAT | Format assigned to the SQL Engine object. |
PROVIDERDBTYPE | It is set to TdType.IntervalDayToSecond. |
DATETIME_PRECISION | The maximum number of digits for the fractional-second component. |
INTERVAL_PRECISION | The maximum number of digits for the Day component. |
The TdDataReader.SchemaTable returns result set metadata. The notable metadata columns for the Interval Day-to-Second data type are:
Column Name | Description |
---|---|
NumericPrecision | The maximum number of digits for the Day component. |
NumericScale | The maximum number of digits for the fractional-second component. |
DataType | System.Type object for the System.TimeSpan structure. |
ProviderType | Set to TdType.IntervalDayToSecond. |
Format | Format assigned to the SQL Engine object. |
ProviderSpecificDataType | System.Type object for the TdIntervalDayToSecond structure. |
The following example shows how to configure an Interval Day-to-Second parameter using DbType type declaration and a Base Class Library (BCL) value. The TdParameter.Precision property reflects the maximum number of digits for the Day component and it must be equal to or less than the target SQL Engine object (i.e. Column, Expression, Stored Procedure Parameters and etc.) declaration. The range of values are from One to Four. 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 SQL Engine object (i.e. Column, Expression, Stored Procedure Parameters and etc.) declaration.
![]() |
---|
The Data Provider will throw an exception if the Day component of the System.TimeSpan value is greater than 9,999 Days. |
![]() |
---|
The Data Provider truncates the fractional seconds to the Scale specified. |
C# |
Copy Code |
---|---|
TdParameter deliveryInterval = new TdParameter(); deliveryInterval.ParameterName = "deliveryDaysAndMinute"; deliveryInterval.DbType = DbType.Object; // Maximum number of Day digits deliveryInterval.Precision = 2; // Maximum number of Fractional-Second digits deliveryInterval.Scale = 3; // 9 Days, 12 Hours, 35 Minutes, 3 seconds and 10 milliseconds. deliveryInterval.Value = new System.TimeSpan(9, 12, 35, 3, 10); |
The following example shows how to configure an Interval Day-to-Second parameter using TdType type declaration and a Provider Specific value. It is recommend to always set TdParameter.Precision and TdParameter.Scale properties, however the Data Provider will utilize TdIntervalDayToSecond.Precision and TdIntervalDayToSecond.Scale property values when the TdParameter.Precision and TdParameter.Scale 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.
![]() |
---|
The Data Provider will throw an exception if the Interval Day Component is greater than the maximum permissible value specified by the TdParameter.Precision property. |
![]() |
---|
The Data Provider truncates the fractional seconds to the Scale specified. |
C# |
Copy Code |
---|---|
TdParameter deliveryInterval = new TdParameter(); deliveryInterval.ParameterName = "deliveryDaysToSecond"; deliveryInterval.TdType = TdType.IntervalDayToSecond; // Maximum number of digits for the Day component deliveryInterval.Precision = 2; // Maximum number of digits for the Fractional-Second component deliveryInterval.Scale = 6; // 9 Days, 12 Hours, 35 Minutes, 3 seconds and 10 microseconds . deliveryInterval.ProviderSpecificValue = new TdIntervalDayToSecond(9, 12, 35, 3, 10); |
The syntax for the Interval Day-to-Second Literal is INTERVALsign'dddd hh:mi:ss.ffffff'DAY TO SECOND. Interval Day-to-Second literals consist of the word Interval followed by an optional negative sign, character string literal representation of the number Days (up to 4 digits ranging from 0 to 9999), Hours (2 digits ranging from 00 to 23), Minutes (2 digits ranging from 00 to 59), Seconds (2 digits ranging from 00 to 59) and Fractional-Seconds (up to 6 digits ranging from 0 to 999999) and the phrase Day To Second.
![]() |
---|
We recommend to always use Parameters in order to take advantage of the SQL Engine's Request Cache. |
The following example shows 10 Days, 3 hours, 59 Minutes, 3 seconds and 10 milliseconds represented as Interval Day-to-Second Literal 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(); // Delivery exceeding 10 days, 3 hours, 59 minutes, 3 seconds and 10 milliseconds. cmd.CommandText = "SELECT Id, orderDate from Order where (CURRENT_DATE - OrderTimestamp) > INTERVAL'10 03:59:03.010'DAY TO SECOND "; using (TdDataReader reader = cmd.ExecuteReader()) { if (reader.HasRows) { while (reader.Read()) { Console.WriteLine("Id={0}", reader.GetInt64(0).ToString()); } } } } |
The following methods and properties return the column or parameter value as a System.TimeSpan structure.
The following methods and properties return the column or parameter value as a TdIntervalDayToSecond 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 Id, orderDate, deliveryDaysAndSeconds from Order where deliveryDaysAndSeconds > ?"; cmd.Parameters.Add("delivery", TdType.IntervalDayToSecond); cmd.Parameters[0].Precison = 2; cmd.Parameters[0].Scale = 3; cmd.Parameters[0].Value = new TimeSpan(10, 3, 59, 3, 10); using (TdDataReader reader = cmd.ExecuteReader()) { if (reader.HasRows) { while (reader.Read()) { Console.WriteLine("[TimeSpan] Delivery Days to Second = {0}", reader.GetValue(2).ToString()); Console.WriteLine("[TdIntervalDayToSecond] Delivery Days to Second = {0}", reader.GetTdIntervalDayToSecond(2).ToString()); } } } } /* Output: [TimeSpan] Delivery Days to Seconds = 11.03:09:00.0000000 [TdIntervalDayToSecond] Delivery Days to Seconds = 11 03:09:00.000 */ |
Accessor Methods for Retrieving Data
Configuring Parameters and Parameter Data Types