DB2 Version 9.7 for Linux, UNIX, and Windows

DB2DateTime Structure

Represents the DB2® TIMESTAMP data type, which is the structure equivalent to the IfxDateTime Informix® namespace structure.

In Version 9.7 Fix Pack 6 and later fix packs, the DB2DateTime structure is available for use only with Informix database server.

Namespace:
IBM.Data.DB2Types
Assembly:
IBM.Data.DB2 (in IBM.Data.DB2.dll)

Syntax

[Visual Basic]
Public Structure DB2DateTime
[C#]
public struct DB2DateTime
[C++]
public value class DB2DateTime

Remarks

A DB2DateTime structure represents a single moment in the span of time from 00:00:00.00000 on 1 January 0001 to 23:59:59.99999 on 31 December 9999.

A DB2DateTime structure consists of separate values of the following time units:
  • Year
  • Month
  • Day
  • Hour
  • Minute
  • Second
  • Fractions of a second: You can further divide the fractions of a second into fraction1, fraction2, fraction3, fraction4, and fraction5.
When creating a DB2DateTime structure you can use all time units or a subset of time units that make up the DB2DateTime structure.
If you create a DB2DateTime structure without specifying all of the time units, the following default values are used for the unspecified time units.
Table 1.
Time unit Default value
Year 1200
Month 1
Day 1
Hour 0
Minute 0
Second 0
Fraction 0

Data server restrictions

The DB2DateTime structure is supported only with theInformix database server.

If the DB2DateTime structure is specified with a database server other than the Informix database server, a NotSupportedException message is thrown.

Example

[C#] You can use the following code to retrieve a single DB2DateTime structure value from a table.

[C#]
  public static string getParam(DB2Connection conn)
  {
    string mySelectQuery = "SELECT * FROM IN_TRAY";
    DB2Command myCommand = new DB2Command(mySelectQuery, conn);
    DB2DataReader reader = myCommand.ExecuteReader();

    if (reader.Read())
    {
      DB2DateTime selectValue = reader.GetDB2DateTime(0);

      if (!selectValue.IsNull) { return selectValue.ToString(); }
    }

    return "NULL";
  }

Thread safety

Any public static (Shared in Visual Basic) members are safe for multithreaded operations. Any instance members are not guaranteed to be thread safe.

Version information

Last update
This topic was last updated for: IBM® DB2 Version 9.7 Fix Pack 6.
.NET Framework version
Supported in: 2.0, 3.0, 3.5, and 4.0
IBM Data Server Client
Supported in: IBM DB2 Version 9.7 Fix Pack 6