GL_DATETIME environment variable

The GL_DATETIME environment variable specifies the custom display format of values in DATETIME columns.

Like DBDATE, DBTIME, and GL_DATE, the GL_DATETIME setting controls only the character-string representation of data values. It has no effect on the internal storage format of DATETIME columns.


In a database where GL_DATETIME has a nondefault setting, you cannot process localized DATETIME values correctly in some operations that load or unload data unless the USE_DTENV environment variable is set to 1. For more information about this dependency of GL_DATETIME on the USE_DTENV setting, see USE_DTENV environment variable.

The setting of a GL_DATETIME format can contain the following characters:
  • One or more white space characters, which the CTYPE category of the locale specifies
  • An ordinary character (other than the % symbol or a white-space character)
  • A formatting directive, which is composed of the % symbol, immediately followed by one or more conversion characters that specifies the required replacement.
    Read syntax diagramSkip visual syntax diagram
                              |                                     (1) |   
                              '-| Optional time format qualifiers |-----'   
    1. See Optional time format qualifiers
Contains the formatting directives that specify the display format for DATETIME values. You can use any formatting directive that formats dates or points in time. (For a list of additional formatting directives for year, month, and day values that are also valid in the GL_DATETIME setting, see GL_DATE environment variable.)

The following list describes the DATETIME formatting directives that are not based on era.

Formatting directives Description
%c Is replaced by a special DATETIME representation that the locale defines.
%Fn Is replaced by the value of the fraction of a second, with precision that is specified by the unsigned integer n. The default value of n is 2; the range of n is 0n5. This value overrides any width or precision between the % and F character. For more information, see Optional time format qualifiers.
%H Is replaced by the hour as an integer (00 through 23) for a 24-hour clock format.
%I Is replaced by the hour as an integer (00 through 11) for a 12-hour clock format.
%M Is replaced by the minute as an integer (00 through 59).
%p Is replaced by the A.M. or P.M. equivalent, as defined in the locale.
%r Is replaced by the commonly used time representation for a 12-hour clock format, including the A.M. or P.M. equivalent, as defined in the locale.
%R Is replaced by the time in 24-hour notation (%H:%M).
%S Is replaced by the second as an integer (00 through 61). The second can be up to 61 instead of 59 to allow for the occasional leap second and double leap second.
%T Is replaced by the time in the %H:%M:%S format.
%X Is replaced by the commonly used time representation as defined in the locale.
%% Is replaced by % (to allow a literal % character in the format string).
Important: Any separator character between the %S and %F directives for DATETIME display formats must be explicitly defined. There is no default separator. Consecutive %S%F directives concatenate the digits representing the integer and fractional parts of the seconds value in the display format.

Within the format string, white space or other nonalphanumeric characters must show between any two formatting directives. Any other characters in the GL_DATETIME setting that were not listed in the table above or in the GL_DATE environment variable description as formatting directives are interpreted as literal characters. If a GL_DATETIME format does not correspond to any of the valid formatting directives, the behavior of the HCL Informix® product when it tries to format DATETIME values is undefined.

GL_DATE environment variable describes additional formatting directives that you can also include in the GL_DATETIME setting to specify the display format of DATETIME values:
%a, %A, %b, %B, %C, %d, %D, %e, %h, %iy, %iY, %m, %n, %t, 
%w, %x, %y, %Y
For example, if you use an U.S. English locale, you might want to format an internal DATETIME YEAR TO SECOND value to the ASCII string format that the following example shows:
Mar 21, 2013 at 16 h 30 m 28 s
To do so, set the GL_DATETIME environment variable as the following line shows:
%b %d, %Y at %H h %M m %S s
Important: The setting of GL_DATETIME affects the behavior of certain Informix ESQL/C library functions if the DBTIME environment variable is not set. For information about how these library functions are affected, see DATETIME-format functions. The setting of DBETIME takes precedence over the setting of GL_DATETIME.

Copyright© 2018 HCL Technologies Limited