Open Client supports six datetime types, CS_DATE, CS_TIME, CS_DATETIME, CS_DATETIME4, CS_BIGDATETIME, and CS_BIGTIME. These datatypes are intended to hold 4-byte and 8-byte datetime values.
The CS_BIGDATETIME and CS_BIGTIME datatypes provide microsecond-level precision for time data. These datatypes are intended to hold 8-byte binary values. These datatypes function similarly to the respective CS_DATETIME and CS_TIME datatypes: The CS_BIGDATETIME datatype can be used anywhere that the CS_DATETIME datatype can be used, and the CS_BIGTIME datatype can be used anywhere that the CS_TIME datatype can be used. All Open Client and Open Server routines that can be applied to the CS_DATETIME and CS_TIME datatypes can also be applied to the CS_BIGDATETIME and CS_BIGTIME datatypes.
An Open Client application uses the CS-Library routine cs_dt_crack to extract date parts (year, month, day, etc.) from a datetime structure.
CS_DATE corresponds to the Adaptive Server Enterprise date datatype. The range of legal CS_DATE values is from January 1, 0001 to December 31, 9999. The definition of CS_DATE is:
typedef CS_INT CS_DATE; /* 4-byte date type*/
CS_TIME corresponds to the Adaptive Server Enterprise time datatype. The range of legal CS_TIME values is from 12:00:00.000 to 11:59:59:999 with a precision of 1/300th of a second (3.33 ms.). The definition of CS_TIME is:
typedef CS_INT CS_TIME; /* 4-byte time type*/
CS_DATETIME corresponds to the Adaptive Server Enterprise datetime datatype. The range of legal CS_DATETIME values is from January 1, 1753 to December 31, 9999, with a precision of 1/300th of a second (3.33 ms.). The definition of CS_DATETIME is:
typedef struct _cs_datetime
{
CS_INT dtdays;
CS_INT dttime;
} CS_DATETIME;
where:
dtdays is the number of days since 1/1/1900.
dttime is the number of 300ths of a second since midnight.
CS_DATETIME4 corresponds to the Adaptive Server Enterprise smalldatetime datatype. The range of legal CS_DATETIME4 values is from January 1, 1900 to June 6, 2079, with a precision of 1 minute. The definition of CS_DATETIME is:
typedef struct _cs_datetime4
{
CS_USHORT days;
CS_USHORT minutes;
} CS_DATETIME4;
where:
days is the number of days since 1/1/1900.
minutes is the number of minutes since midnight.
CS_BIGDATETIME corresponds to the Adaptive Server Enterprise bigdatetime datatype and contains the number of microseconds that have passed since January 1, 0000 00:00:00.000000. The range of legal CS_BIGDATETIME values is from January 1, 0001 00:00:00.000000 to December 31, 9999 23:59:59.999999.
January 1, 0000 00:00:00.000000 is the base starting value from which microseconds are counted. Any value earlier than January 1, 0001 00:00:00.000000 is invalid.
The definition of CS_BIGDATETIME can be found in cstypes.h:
typedef CS_UBIGINT CS_BIGDATETIME;
CS_BIGTIME corresponds to the Adaptive Server Enterprise bigtime datatype and indicates the number of microseconds that have passed since the beginning of the day. The range of legal CS_BIGTIME values is from 00:00:00.000000 to 23:59:59.999999. The definition of CS_BIGTIME can be found in cstypes.h:
typedef CS_UBIGINT CS_BIGTIME;
CS_BIGDATETIME and CS_BIGTIME data is presented to the client in the native-byte order (endianness) of the underlying client platform. Any necessary byte-swapping is performed at the server before the data is sent to the client, or after the data is received from the client.