Field specification for displaying a DATE value

When the HCL OneDB™ product uses a display format to print a date string, the field specification defines the number of characters to print as output.

The syntax for the field specification is as follows.
Figure 1: Format qualifiers for output

1  
2.1 -
2.1 0
1? ? width? .? precision
Element
Description
- (minus sign)
Field value is left-aligned and begins with a digit; value can include trailing blank spaces.
0 (zero)
Field value is right-aligned; any zeros on the left are pad characters; they are not significant.
width
Integer that indicates a minimum field width for the printed value.
precision
Integer that indicates the precision to use for the field value.
The meaning of the precision value depends on the formatting directive with which it is used, as the following table shows.
Formatting Directives Description
%C, %d, %e, %Ey, %iy, %iY,%m, %w, %y, %Y Value of precision specifies the minimum number of digits to print. If a value supplies fewer digits than precision specifies, the HCL OneDB product pads the value with leading zeros. The %d, %Ey, %iy, %m, %w, and %y formatting directives have a default precision of 2. The %Y directive has no precision default; year 0001 would be formatted as 1 rather than as 0001.
%a, %A, %b, %B, %EC, %Eg, %h Value of precision specifies the maximum number of characters to print. If a value supplies more characters than precision specifies, the HCL OneDB product truncates the value.
%D Values of width and precision affect each element of these formatting directives. For example, the field specification %6.4D causes a DATE value to be displayed as if the format were: %6.4m/%6.4d/%6.4y where no fewer than four (but no more than six) characters represented the month, day, and year values, in that order, with “/” as the separator.
%Ox For formatting directives that include the O modifier (alternative digits), the value of precision is still the minimum number of digits to print. The width value defines the format width rather than the actual number of digits.
%Ex, %EY, %n, %t, %x, %% Values of width and precision have no effect on these formatting directives.

For example, the following formatting directive displays the month as an integer with a maximum field width of 4: %4m

The following formatting directive displays the day of the month as an integer with a minimum field width of 3 and a maximum field width of 4: %4.3d