SQL/MX Programming Manual for C and COBOL (G06.24+, H06.03+)
Host Variables in COBOL Programs
HP NonStop SQL/MX Programming Manual for C and COBOL—523627-004
4-15
Date-Time and Interval Data
 ...
EXEC SQL END DECLARE SECTION END-EXEC. 
 ...
 EXEC SQL SELECT custnum, billing_date 
 INTO :HV-CUSTNUM, :HV-BILLING-DATE 
 FROM billings 
 WHERE custnum = :HV-THIS-CUSTOMER 
 END-EXEC.
 ...
Inserting or Updating Standard Date-Time Values
To insert or update standard date-time values (DATE, TIME, or TIMESTAMP, or the 
SQL/MP DATETIME equivalents) in the database, format the date-time values in the 
desired display format for a date, time, or timestamp. Within an INSERT or UPDATE 
statement, use the DATE, TIME, or TIMESTAMP data type. 
Example
If a database has a BILLINGS table that consists of the CUSTNUM and 
BILLING_DATE columns, this example inserts a customer number and date-time value 
into that table:
EXEC SQL BEGIN DECLARE SECTION END-EXEC.
 ...
01 BILLINGS-REC.
 02 HV-CUSTNUM PIC 9(4) COMP.
 02 HV-BILLING-DATE DATE.
 ...
EXEC SQL END DECLARE SECTION END-EXEC.
 ...
 EXEC SQL INSERT INTO billings
 VALUES (:HV-CUSTNUM, :HV-BILLING-DATE)
 END-EXEC.
 ...
Selecting SQL/MP DATETIME Values Not Equivalent to 
DATE, TIME, or TIMESTAMP
To retrieve nonstandard SQL/MP DATETIME values that are not equivalent to DATE, 
TIME, or TIMESTAMP, declare a COBOL character array the same length as the 
number of bytes you expect to store in the array. For a list of nonstandard SQL/MP 
DATETIME data types, see the SQL/MX Reference Manual.
Use the SQL/MX CAST function to convert a date-time column in a select list to a 
character string. You must also specify the length in the AS clause of the CAST 
function to be the length of the declared host variable.
Example
Suppose that an SQL/MP database has a BILLINGS table that consists of the 
CUSTNUM and BILLING_DATE columns. The BILLING_DATE column has a 
COBOL










