Open Client supports four datetime types: CS_DATE, CS_TIME, CS_DATETIME, and CS_DATETIME4. These datatypes are intended to hold 8-byte and 4-byte datetime values:
CS_DATE corresponds to the Adaptive Server date datatype with a range of legal values from January 1, 0001 to December 31, 9999.
CS_TIME corresponds to the Adaptive Server time datatype, with a range of legal values from 12:00:00.000 to 11:59:59:999 with a precision of 1/300th of a second (3.33 ms).
CS_DATETIME corresponds to the Adaptive Server datetime datatype, with a range of legal values from January 1, 1753 to December 31, 9999, with a precision of 1/300th of a second (3.33 ms).
CS_DATETIME4 corresponds to the Adaptive Server smalldatetime datatype, with a range of legal values from January 1, 1900 to June 6, 2079, with a precision of 1 minute.
An application can call the CS-Library routine cs_convert to initialize a datetime type from a character string. cs_convert recognizes all of the date and time formats valid for Transact-SQL datetime character strings. See the “Datatypes” topic in the Adaptive Server Enterprise Reference Manual for more information about these formats.
cs_convert can also convert a CS_DATETIME or CS_DATETIME4 value into a character string.
Other routines that are useful when working with datetime values include:
cs_cmp, which compares two data values.
cs_dt_crack, which maps a datetime value to a CS_DATEREC structure. A CS_DATEREC contains distinct fields for the different parts of a datetime value.
cs_dt_info, which retrieves language-specific datetime information such as day names. This routine also configures the format for converting datetime data values to character strings.
cs_convert, cs_cmp, cs_dt_crack, and cs_dt_info use locale information that is specified indirectly, using the CS_CONTEXT, or directly, using a CS_LOCALE structure. (See “CS_LOCALE”.) An application can change the locale information for a CS_CONTEXT by calling cs_config to set the CS_LOC_PROP property for the context.