SQL/MX Programming Manual for C and COBOL (G06.24+, H06.03+)

Host Variables in C/C++ Programs
HP NonStop SQL/MX Programming Manual for C and COBOL523627-004
3-23
Date-Time and Interval Data
representation. Despite this conversion, the precision of Tandem floating-point data
types are maintained correctly in IEEE floating-point format. A Tandem REAL or
FLOAT with precision between 1 and 22 cannot be converted to IEEE REAL because
the Tandem exponent will not fit in an IEEE REAL data type. Although no equivalent
exists for single-precision Tandem REAL and FLOAT in IEEE floating-point format, the
conversion to IEEE DOUBLE preserves the precision and the exponent.
If you want a small floating-point data type with a smaller exponent and less storage,
consider declaring the host variables as float. If you want more exponent and a
larger precision, consider declaring the host variables as double or float(p).
For more information on floating-point formats, see the SQL/MX Reference Manual.
Date-Time and Interval Data
Use the following for date-time and interval data types:
For SQL/MP DATETIME data types that are not equivalent to DATE, TIME, or
TIMESTAMP, you are still required to declare a character array host variable and use
the CAST function for input to and output from date-time or interval columns, similar to
SQL/MX Release 1.8, which does not support ANSI-99 date-time host variables.
DATE Representation
You can insert or retrieve date-time values in any of three formats, independently of the
SQL column definition. For example, you can specify formats such as 09/15/1993,
1993-09-15, or 15.09.1993. You control the display format by inserting the value in the
format you want and retrieving the value by using the DATEFORMAT function. See the
DATEFORMAT function in the SQL/MX Reference Manual.
For example, if a table in the database has this column definition:
HIRE_DATE DATE
The host variable representation for December 22, 1988, in DEFAULT format is:
A DATE host variable in DEFAULT format is represented as an 11-character string,
including 10 characters—with hyphens (-) as field separators—plus a character (empty
space) for a null terminator.
DATE Represents a date.
TIME Represents a time.
TIMESTAMP Represents a timestamp.
INTERVAL Represents a duration of time as a year-month or day-time
interval.
1 9 8 8 1 2 2 2
−−
Year Separator Month Separator Day
Null