FORMAT clause

The FORMAT clause specifies the general characteristics and editing requirements of an elementary date, time, or timestamp item.

FORMAT Clause - Format

Read syntax diagramSkip visual syntax diagramFORMATOF DATETIMETIMESTAMP ISliteral-2phrase 1phrase 2
phrase 1
Read syntax diagramSkip visual syntax diagramSIZEISinteger-4 LOCALEISmnemonic-name-1
phrase 2
Read syntax diagramSkip visual syntax diagramSIZEISinteger-5 LOCALEISmnemonic-name-2

The FORMAT clause must be specified for every elementary date, time, or timestamp item, except the subject of a RENAMES clause.

If the SIZE phrase is not specified for a timestamp item, the size defaults to 26. If it is specified, it must have a value of 19, or a value between 21 and 32.

literal-2 and the LOCALE phrase cannot be specified for a timestamp item. A timestamp has a fixed format, which is dependent on the size of the timestamp item.
  • When the SIZE phrase is not specified, the format is equivalent to a literal-2 value of "@Y-%m-%d-%H.%M.%S.@Sm".
  • When the SIZE phrase is specified with a value of 19, the format is equivalent to a literal-2 value of "@Y-%m-%d-%H.%M.%S".
  • When the SIZE phrase is specified as a value between 21 and 32, the format is equivalent to a literal-2 value of "@Y-%m-%d-%H.%M.%S." followed by the fractional seconds in the timestamp. For example, a timestamp with size 25 could have the value "2014-01-23-01.02.03.12345".

If literal-2 or the LOCALE phrase is not specified for a date or time item, the format of the item is determined from the SPECIAL-NAMES FORMAT clause.

A data item of class date-time cannot be reference modified.

When the FORMAT clause is specified, the following clauses cannot be specified:
  • PICTURE clause.
  • SIGN clause.
  • BLANK WHEN ZERO clause.
  • JUSTIFIED clause.
  • LIKE clause. A LIKE clause can, however, be used to define the FORMAT of a data item. You cannot change the size of a date, time, or timestamp item with a LIKE clause. When a LIKE clause is referring to a date, time, or timestamp item, a comment is generated with the appropriate FORMAT clause information that is inherited
  • TYPE clause.
The following general rules apply:
  • A condition-name can be associated with a date-time item. The VALUE clause of the condition-name can be specified with a THRU phrase.
  • A SYNCHRONIZED clause is treated as documentation.
  • The OCCURS, REDEFINES, and RENAMES clauses can be associated with date, time, or timestamp items.
  • If a LIKE clause is specified, a FORMAT clause cannot be specified.
  • Any associated VALUE clause must specify a non-numeric literal. The literal is treated exactly as specified; no formatting is done.
literal-2
Specifies the format of a date or time item. literal-2 must be a non-numeric literal, at least 2 characters long. The contents of literal-2 is made up of separators and conversion specifiers. For a list of valid conversion specifiers, see the Conversion specifiers that can be used in literal-8 table. For further rules on the contents of literal-2, see the description of the FORMAT clause used in the SPECIAL-NAMES paragraph in FORMAT clause.