The year formatting directives

You can use these formatting directives in the display format of the GL_DATE environment variable to format the year of a date string: %y, %iy, %Y, and %iY.

The %iy and %iY formatting directives provide compatibility with the Y2 and Y4 year specifiers of the DBDATE environment variable.

When the HCL® OneDB® product uses a display format to print an internal date value as a string, the %iy directive performs the same task as % y, and %iY directive performs the same task as %Y. To print a year with one of these formatting directives, the HCL OneDB product performs the following actions:
  • The %iy and %y formatting directives both print the year of an internal date value as a two-digit decade.

    For example, when you set GL_DATE to '%y %m %d' or '%iy %m %d', an internal date for March 5, 1997 formats to '97 03 05'.

  • The %iY and %Y formatting directives both print the year of an internal date value as a four-digit year.

    For example, when you set GL_DATE to '%Y %m %d' or '%iY %m %d', the internal date for March 5, 1997 formats to '1997 03 05'.

When the HCL OneDB product uses a display format to read a date, the %iy formatting directive performs differently from %y and the %iY formatting directive performs differently %Y. The following table summarizes how the year formatting directives behave when the HCL OneDB product uses them to read date strings.
Table 1. GL_DATE formats with sample date strings

GL_DATE formats with sample date strings

GL_DATE format '1994 03 06' date string to read '94 03 06' date string to read
%y %m %d Error Internal date for 1994 03 06
%iy %m %d Internal date for 1994 03 06 Internal date for 1994 03 06
%Y %m %d Internal date for 1994 03 06 Internal date for 0094 03 06
%iY %m %d Internal date for 1994 03 06 Internal date for 1994 03 06

In a read of a date string, the %iy and %y formatting directives both prefix the first two digits of the current year to expand any one-digit or two-digit year. You can set the DBCENTURY environment variable to change this default.