TIME

Data Format

Default and alternative time value formats vary. If using DB2 ECM, consult IBM documentation on differing formats. For OpenESQL, review the TIME and TIMEDELIM SQL compiler directive option topics for more information.

For example, one supported time format is:
hh:mm:ss
An example value for this format is:
12:34:00

Host Variable Formats

OpenESQL and DB2 ECM
01 time1         PIC X(8).
OpenESQL
01 time2         SQL TYPE IS TIME.
01 time3         PIC X(n).
01 time4         SQL TYPE IS TIME-RECORD.
time1 format
  • Move time data into a host variable using any of these forms:
    MOVE "hh:mm:ss" TO host-var.
    MOVE "hh.mm.ss" TO host-var.
    MOVE "hh:mm PM" TO host-var.
  • Review the DETECTDATE SQL compiler directive option topic to determine whether or not it applies to your application.
time2 format
  • Move time data into a host variable using these forms:
    MOVE "hh:mm:ss" TO host-var.
    MOVE "hh.mm.ss" TO host-var.
    MOVE "hh:mm PM" TO host-var.
  • Preferred format - use whenever possible.
  • Uses the TIME SQL TYPE.
  • Similar to the time1 format, but when using Visual COBOL version 2.3 or later, never requires DETECTDATE for input host variable processing.
time3 format
Use this format when your application moves time data to host variables using ODBC escape sequences.
Note: This format is deprecated starting with Visual COBOL version 2.3. Instead, we strongly suggest that you use the TIME and TIMEDELIM SQL compiler directive options to avoid using ODBC escape sequences.
  • Move time data into host variables using the form:
    MOVE "{t 'hh:mm:ss'}" TO host-var. 
  • Compile applications with the DETECTDATE SQL compiler directive option to ensure that OpenESQL evaluates PIC X fields for possible time formats in input host variables.
  • Ensure n is large enough to accommodate the time value plus the characters used by the ODBC escape sequence.
  • Output host variable values are returned without the ODBC escape sequence.
time4 format
  • Move time data into host variables using this form:
    MOVE hh TO host-var-hour
    MOVE mm TO host-var-min
    MOVE ss TO host-var-sec
  • Uses the TIME-RECORD SQL TYPE.