
'Declaration Public Structure TdDate Inherits System.ValueType Implements System.Data.SqlTypes.INullable, System.IComparable, System.IComparable(Of TdDate), System.IConvertible, System.IEquatable(Of TdDate), System.IFormattable, System.Xml.Serialization.IXmlSerializable
'Usage Dim instance As TdDate
public struct TdDate : System.ValueType, System.Data.SqlTypes.INullable, System.IComparable, System.IComparable<TdDate>, System.IConvertible, System.IEquatable<TdDate>, System.IFormattable, System.Xml.Serialization.IXmlSerializable
public value class TdDate : public System.ValueType, System.Data.SqlTypes.INullable, System.IComparable, System.IComparable<TdDate>, System.IConvertible, System.IEquatable<TdDate>, System.IFormattable, System.Xml.Serialization.IXmlSerializable
The .Net Framework does not have a system type that directly corresponds to the Teradata type Date. Version 1.2 and earlier of the provider map Date to System.DateTime. With the release of version 12.0 of the provider, TdDate is available to retrieve and manipulate data of type Date.
The date can range from January 01, 0001 to December 31, 9999.
An application can use the TdDate structure the same way that a System.DateTime is used. TdDate can be used with any version of Teradata supported by the .Net Data Provider for Teradata.
A TdDate can also be specified as an In, Out, or InOut parameter to a Stored Procedure. In order to maintain backward compatibility with previous versions of the provider --versions earlier than 12.0--, the Connection String Attribute Enable TdDateTime must be set to false
. When this is done, a TdDate is returned to an application using the TdParameter.ProviderSpecificValue property. The object that is returned from the TdParameter.Value property remains a System.DateTime.
If the attribute Enable TdDateTime is set to true
a TdDate is returned to the application through the TdParameter.Value.
Public void DateExample(TdCommand cmd, String classId) { cmd.Parameter.Clear(); cmd.CommandText = "SELECT StartDate, EndDate " + "FROM ClassEnrollment " + "WHERE ClassId = ?"; 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, classId); TdDataReader dr = null; Int32 i = 0; Try { dr = cmd.ExecuteReader(); If (false == dr.Read()) { return; } TdDate [] startDate = new TdDate[dr.RecordsReturned]; TdDate [] endDate = new TdDate[dr.RecordsReturned]; // An additional 5 days will be added to the start and end dates. // The updates will be done the hard way. All the records will // be read, 5 days will be added to the dates, and then each // record will be updated. // Specifying a TimeSpan of 5 days System.TimeSpan fiveExtraDays = new TimeSpan(5, 0, 0, 0); while (false == dr.Read()) { // Retrieving the dates startDate[i] = dr.GetTdDate(0); endDate[i] = dr.GetTdDate(1); // Going to add 5 days to the StartDate startDate[i] = startDate[i] + fiveExtraDays // Going to add 5 days to the EndDate endDate[i] = endDate[i] + fiveExtraDays; i++; } } finally { if (dr != null) { dr.Close(); } } cmd.Parameters.Clear(); cmd.CommandText = "UPDATE classEnrollment " + "SET StartDate = ?, EndDate = ? " + "WHERE ClassId = ?"; cmd.Parameters.Add(null, TdType.Date, 0, System.Data.ParameterDirection.Input, true, 0, 0, null, System.Data.DataRowVersion.Default, null); cmd.Parameters.Add(null, TdType.Date, 0, System.Data.ParameterDirection.Input, true, 0, 0, null, System.Data.DataRowVersion.Default, null); cmd.Parameters.Add(null, TdType.Varchar, 9, System.Data.ParameterDirection.Input, true, 0, 0, null, System.Data.DataRowVersion.Default, classId); i--; while(i >= 0) { cmd.Parameters[0].Value = startDate[i]; cmd.Parameters[1].Value = endDate[i]; cmd.ExecuteNonQuery(); i--; } }
System.Object
System.ValueType
Teradata.Client.Provider.TdDate
Target Platforms: Windows 8.1, Windows 10, Windows Server 2012 R2, Windows Server 2016, Windows Server 2019
TdDate Members
Teradata.Client.Provider Namespace
Date And Time Connection String Attribute
Enabling Provider Specific Types
Provider Specific Type: Date And Time Overview