The FORMAT clause is used to specify a default format for a DATA DIVISION date or time item. The format clause can also specify the default date or time format for an intrinsic function.
FORMAT Clause - Format >>-FORMAT--+----+--+-DATE-+--+----+-----------------------------> '-OF-' '-TIME-' '-IS-' >--+-literal-8--+--------------------------------------------+-+->< | '-| SIZE Phrase 1 |--+---------------------+-' | | '-| LOCALE Phrase 1 |-' | '-SIZE--+----+--integer-4--LOCALE--+---------------------+--' '-IS-' '-IS--mnemonic-name-4-' SIZE Phrase 1 |--SIZE--+----+--integer-3--------------------------------------| '-IS-' LOCALE Phrase 1 |--LOCALE--+---------------------+------------------------------| '-IS--mnemonic-name-3-'
Table 1 lists the conversion specifiers that can be used in literal-8.
| Specifier | Description | Length | Allowed For |
|---|---|---|---|
| @C | Replaced by the century as an integer [0,9] (0⁴ 20th century) | 1 bytes | D |
| %d | Replaced by the day of month as an integer [01,31] | 2 bytes | D |
| %D | Same as %m/%d/%y | 8 bytes | D |
| %H | Replaced by the hour (24-hour clock) as an integer [00,23] | 2 bytes | T |
| %I | Replaced by the hour (12-hour clock) as an integer [01,12] | 2 bytes | T |
| %j | Replaced by the day of the year as an integer [001,366] | 3 bytes | D |
| %m | Replaced by the month as an integer [01,12] | 2 bytes | D |
| %M | Replaced by the minute as an integer [00,59] | 2 bytes | T |
| %p | Replaced by the locale's equivalent of either a.m. or p.m. | locale | T |
| @p | AM and PM can be any mix of upper and lower case | 2 bytes | T |
| %r | Replaced by the time in a.m. and p.m. notation; in the POSIX locale this is equivalent to %I:%M:%S %p | locale, at least 8 bytes | T |
| %R | Replaced by the time in 24 hour notation [%H:%M] | 5 bytes | T |
| %S | Replaced by the second as an integer [00,61] | 2 bytes | T |
| @Sh | Replaced by the hundredths of a second as an integer [00,99] | 2 bytes | T |
| @Sm | Replaced by the millionths of a second as an integer [000000,999999] | 6 bytes | T |
| @So | Replaced by the thousandths of a second as an integer [000,999] | 3 bytes | T |
| @St | Replaced by the tenths of a second as an integer [0,9] | 1 bytes | T |
| %y | Replaced by the year without century as an integer [00,99] | 2 bytes | D |
| %Y | Replaced by the year with century as an integer | usually 4 bytes | D |
| @Y | Replaced by the year with century as an integer | 4 bytes | D |
| %% | Replaced by a % | 1 byte | D, T |
| @@ | Replaced by a @ | 1 byte | D, T |
Table 5 notes:
|
|||