
'Declaration Public Structure TdTime Inherits System.ValueType Implements System.Data.SqlTypes.INullable, System.IComparable, System.IComparable(Of TdTime), System.IConvertible, System.IEquatable(Of TdTime), System.IFormattable, System.Xml.Serialization.IXmlSerializable
'Usage Dim instance As TdTime
public struct TdTime : System.ValueType, System.Data.SqlTypes.INullable, System.IComparable, System.IComparable<TdTime>, System.IConvertible, System.IEquatable<TdTime>, System.IFormattable, System.Xml.Serialization.IXmlSerializable
public value class TdTime : public System.ValueType, System.Data.SqlTypes.INullable, System.IComparable, System.IComparable<TdTime>, System.IConvertible, System.IEquatable<TdTime>, System.IFormattable, System.Xml.Serialization.IXmlSerializable
The .Net Framework does not have a system type that directly corresponds to the Teradata type Time. The .Net Data Provider for Teradata Version 1.2 and earlier versions map Time to System.TimeSpan. With the release of version 12.0 of the provider, TdTime is available to retrieve and manipulate data of Teradata type Time.
Similar to the SQL Time data type, the TdTime also supports a scale for the sub-seconds --this is referred to as TdTime.Microsecond. The scale can range from 0 to 6. The microseconds and scale are specified in the constructor. An example of a time is "17:22:10.0329". This time has a TdTime.Microsecond of "32900", and a TdTime.Scale of "4".
When a TdTime is parsed (see TdTime.Parse) the scale of the resulting TdTime will be set to the actual scale of the fractional component of the time.
When data of a column that is a Time is retrieved as a TdTime, it's scale will be set to the scale of the column.
The TdTime structure allows arithmetic, comparison, and conversion operations to be performed.
A TdTime value 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 TdTime is returned to an application using the TdParameter.ProviderSpecificValue property. The object that is returned from the TdParameter.Value property remains a System.TimeSpan object.
If the attribute Enable TdDateTime is set to true
a TdTime is returned to the application through the TdParameter.Value.
The following example retrieves data of two TIME columns from Teradata, modifies the data, and then updates the record with the new data contained in TdTime.
Public void TimeExample(TdCommand cmd, String classId) { cmd.Parameters.Clear(); cmd.CommandText = "SELECT StartTime, EndTime FROM ClassInfo " + "WHERE ClassId = ?"; cmd.CommandType = CommandType.Text; cmd.Parameters.Add(null, TdType.Varchar, 9, System.Data.ParameterDirection.Input, true, 0, 0, null, System.Data.DataRowVersion.Default, classid); TdDataReader dr = null; // This will be added to TdTime. The timespan has been set to 1 hour. Timespan hourLater = new Timespan(1, 0, 0); // Going to add an hour to the start and end times of the class. // This is going to be done the hard way to demonstrate TdTime. Try { dr = cmd.ExecuteReader(); dr.Reader(); // Only one record is returned from query TdTime startTime = dr.GetTdTime (0); TdTime endTime = dr.GetTdTime (1); dr.Close(); startTime = startTime + hourLater; endTime = endTime + hourLater; // Going to update the class record to indicate that the // class will start an hour later. cmd.CommandText = "UPDATE ClassInfo " + "SET StartTime = ?, EndTime = ? " + "WHERE ClassId = ?"; cmd.Parameters.Clear(); cmd.Parameters.Add(null, TdType.Time, 0, System.Data.ParameterDirection.Input, true, 0, 0, null, System.Data.DataRowVersion.Default, startTime); cmd.Parameters.Add(null, TdType.Time, 0, System.Data.ParameterDirection.Input, true, 0, 0, null, System.Data.DataRowVersion.Default, startTime); cmd.Parameters.Add(null, TdType.Varchar, 9, System.Data.ParameterDirection.Input, true, 0, 0, null, System.Data.DataRowVersion.Default, classid); cmd.ExecuteNonQuery(); } finally { if (dr != null) { dr.Close(); } } }
System.Object
System.ValueType
Teradata.Client.Provider.TdTime
Target Platforms: Windows 8.1, Windows 10, Windows Server 2012 R2, Windows Server 2016, Windows Server 2019
TdTime Members
Teradata.Client.Provider Namespace
Date And Time Connection String Attribute
Enabling Provider Specific Types
Provider Specific Type: Date And Time Overview