Send feedback on this topic.
Teradata.Client.Provider
TdTimeWithTimeZone Structure
Members  Example 



Teradata.Client.Provider Namespace : TdTimeWithTimeZone Structure
TdTimeWithTimeZone is a .Net Data Provider for Teradata specific type that represents the time of day, and allows a Time Zone to be specified.
Object Model
TdTimeWithTimeZone StructureTdTimeWithTimeZone StructureTdTimeWithTimeZone StructureTdTimeWithTimeZone StructureTdTimeWithTimeZone Structure
Syntax
Remarks

The .Net Framework 2.0 does not contain a system type that directly corresponds to the Teradata type Time With Time Zone. The .Net Data Provider for Teradata version 1.2 and earlier maps System.String to Time With Time Zone. With the release of version 12.0 of the provider, TdTimeWithTimeZone is available to retrieve and manipulate data of Teradata type Time With Time Zone.

TdTimeWithTimeZone supports Time Zones by allowing a Universal Coordinated Time (UTC) Offset to be specified with a time. A valid UTC Offset will be within the range of -12:59 to 13:00.

The UTC offset can be specified when invoking the constructor, or in a string that is to be parsed. For more information on UTC offset refer to the Teradata Manual, Sql Reference: DataTypes and Literals.

Similar to the SQL Time With Time Zone data type, the TdTimeWithTimeZone also supports a scale for the sub-seconds --this is specified as a TdTimeWithTimeZone.Microsecond. The scale can range from 0 to 6. The microseconds and scale are specified in the constructor. An example of a time with a time zone is "17:22:10.0329-08:00". This time has a UTC offset of "-08:00", Microsecond of "32900", and a Scale of "4".

When a TdTimeWithTimeZone is parsed (see TdTimeWithTimeZone.Parse) the scale of the resulting TdTimeWithTimeZone will be set to the actual scale of the fractional part of the TdTimeWithTimeZone.

When data of a column that is a Time With Time Zone is retrieved as a TdTimeWithTimeZone, it's scale will be set to the scale of the column.

The TdTimeWithTimeZone structure allows arithmetic, comparison, and conversion operations to be performed.

A TdTimeWithTimeZone 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 TdTimeWithTimeZone is returned to an application using the TdParameter.ProviderSpecificValue property. The object that is returned using the TdParameter.Value property remains a System.String object.

.

If the attribute Enable TdDateTime is set to true a TdTimeWithTimeZone is returned to the application through the TdParameter.Value.

The TdTimeWithTimeZone is daylight savings time agnostic.

Example
The following example retrieves data of two TIME WITH TIME ZONE columns from Teradata, modifies the data, and then updates the record with the new data contained in TdTimeWithTimeZone.
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();
            
      // Only one record is returned from query
      TdTimeWithTimeZone startTime = dr.GetTdTimeWitTimeZone(0);
      TdTimeWithTimeZone endTime = dr.GetTdTimeWithTimeZone(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.TimeWithTimeZone, 0,
         System.Data.ParameterDirection.Input, true, 0, 0, null,    
         System.Data.DataRowVersion.Default, startTime);
            
      cmd.Parameters.Add(null, TdType.TimeWithTimeZone, 0,
         System.Data.ParameterDirection.Input, true, 0, 0, null,    
         System.Data.DataRowVersion.Default, endTime);
            
      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();
      }
   }
}
Inheritance Hierarchy

System.Object
   System.ValueType
      Teradata.Client.Provider.TdTimeWithTimeZone

Requirements

Target Platforms: Windows 8.1, Windows 10, Windows Server 2012 R2, Windows Server 2016, Windows Server 2019

See Also

Reference

TdTimeWithTimeZone Members
Teradata.Client.Provider Namespace
Date And Time Connection String Attribute
Enabling Provider Specific Types
Provider Specific Type: Date And Time Overview