Input Data Specification

The following general rules apply to date and time input formats:

  • The century value for two-digit years is defined by the SET EPOCH value. By default, the century range begins 69 years prior to the current year and ends 30 years after the current year. Whether all four digits or only two digits are displayed in output depends on the width specification on the format.
  • Dashes, periods, commas, slashes, or blanks can be used as delimiters in the input values. For example, with the DATE format, the following input forms are all acceptable:

    28-OCT-90 28/10/1990 28.OCT.90 28 October, 1990

    The displayed values, however, will be the same: 28-OCT-90 or 28-OCT-1990, depending on whether the specified width allows 11 characters in output.

  • The JDATE format does not allow internal delimiters and requires leading zeros for day values of less than 100 and two-digit-year values of less than 10. For example, for January 1, 1990, the following two specifications are acceptable:

    90001 1990001

    However, neither of the following is acceptable:

    90 1 90/1

  • Months can be represented in digits, Roman numerals, or three-character abbreviations, and they can be fully spelled out. For example, all of the following specifications are acceptable for October:

    10 X OCT October

  • The quarter in QYR format is expressed as 1, 2, 3, or 4. It must be separated from the year by the letter Q. Blanks can be used as additional delimiters. For example, for the fourth quarter of 1990, all of the following specifications are acceptable:

    4Q90 4Q1990 4 Q 90 4 Q 1990

    On some operating systems, such as IBM CMS, Q must be upper case. The displayed output is 4 Q 90 or 4 Q 1990, depending on whether the width specified allows all four digits of the year.

  • The week in the WKYR format is expressed as a number from 1 to 53. Week 1 begins on January 1, week 2 on January 8, and so on. The value may be different from the number of the calendar week. The week and year must be separated by the string WK. Blanks can be used as additional delimiters. For example, for the 43rd week of 1990, all of the following specifications are acceptable:

    43WK90 43WK1990 43 WK 90 43 WK 1990

    On some operating systems, such as IBM CMS, WK must be upper case. The displayed output is 43 WK 90 or 43 WK 1990, depending on whether the specified width allows enough space for all four digits of the year.

  • In time specifications, colons can be used as delimiters between hours, minutes, and seconds. Hours and minutes are required, but seconds are optional. A period is required to separate seconds from fractional seconds. Hours can be of unlimited magnitude, but the maximum value for minutes is 59 and for seconds 59.999. . . .
  • Data values can contain a sign (+ or –) in TIME and DTIME formats to represent time intervals before or after a point in time.

Example: DATE, ADATE, and JDATE

DATA LIST FIXED
 /VAR1 1-17 (DATE) VAR2 21-37 (ADATE) VAR3 41-47 (JDATE).
BEGIN DATA
28-10-90            10/28/90            90301
28.OCT.1990         X 28 1990           1990301
28 October, 2001    Oct.  28, 2001      2001301
END DATA.
LIST.
  • Internally, all date format variables are stored as the number of seconds from 0 hours, 0 minutes, and 0 seconds of Oct. 14, 1582.

The LIST output from these commands is shown in the following figure.

Figure 1. Output illustrating DATE, ADATE, and JDATE formats
       VAR1             VAR2           VAR3

28-OCT-1990       10/28/1990        1990301
28-OCT-1990       10/28/1990        1990301
28-OCT-2001       10/28/2001        2001301

Example: QYR, MOYR, and WKYR

DATA LIST FIXED /VAR1 1-10 (QYR) VAR2 12-25 (MOYR) VAR3 28-37 (WKYR).
BEGIN DATA
4Q90       10/90           43WK90
4 Q 90     Oct-1990        43 WK 1990
4 Q 2001   October, 2001   43 WK 2001
END DATA.
LIST.
  • Internally, the value of a QYR variable is stored as midnight of the first day of the first month of the specified quarter, the value of a MOYR variable is stored as midnight of the first day of the specified month, and the value of a WKYR format variable is stored as midnight of the first day of the specified week. Thus, 4Q90 and 10/90 are both equivalent to October 1, 1990, and 43WK90 is equivalent to October 22, 1990.

The LIST output from these commands is shown in the following figure.

Figure 2. Output illustrating QYR, MOYR, and WKYR formats
    VAR1       VAR2             VAR3

4 Q 1990   OCT 1990       43 WK 1990
4 Q 1990   OCT 1990       43 WK 1990
4 Q 2001   OCT 2001       43 WK 2001

Example: TIME

DATA LIST FIXED
 /VAR1 1-11 (TIME,2) VAR2 13-21 (TIME) VAR3 23-28 (TIME).
BEGIN DATA
1:2:34.75   1:2:34.75 1:2:34
END DATA.
LIST.
  • TIME reads and writes time of the day or a time interval.
  • Internally, the TIME values are stored as the number of seconds from midnight of the day or of the time interval.

The LIST output from these commands is shown in the following figure.

Figure 3. Output illustrating TIME format
       VAR1      VAR2   VAR3

 1:02:34.75   1:02:34   1:02

Example: WKDAY and MONTH

DATA LIST FIXED
 /VAR1 1-9 (WKDAY) VAR2 10-18 (WKDAY)
  VAR3 20-29 (MONTH) VAR4 30-32 (MONTH) VAR5 35-37 (MONTH).
BEGIN DATA
Sunday   Sunday    January   1    Jan
Monday   Monday    February  2    Feb
Tues     Tues      March     3    Mar
Wed      Wed       April     4    Apr
Th       Th        Oct       10   Oct
Fr       Fr        Nov       11   Nov
Sa       Sa        Dec       12   Dec
END DATA.
FORMATS VAR2 VAR5 (F2).
LIST.
  • WKDAY reads and writes the day of the week; MONTH reads and writes the month of the year.
  • Values for WKDAY are entered as strings but stored as numbers. They can be used in arithmetic operations but not in string functions.
  • Values for MONTH can be entered either as strings or as numbers but are stored as numbers. They can be used in arithmetic operations but not in string functions.
  • To display the values as numbers, assign an F format to the variable, as was done for VAR2 and VAR5 in the above example.

The LIST output from these commands is shown in the following figure.

Figure 4. Output illustrating WKDAY and MONTH formats
     VAR1 VAR2       VAR3 VAR4 VAR5

SUNDAY      1  JANUARY     JAN   1
MONDAY      2  FEBRUARY    FEB   2
TUESDAY     3  MARCH       MAR   3
WEDNESDAY   4  APRIL       APR   4
THURSDAY    5  OCTOBER     OCT  10
FRIDAY      6  NOVEMBER    NOV  11
SATURDAY    7  DECEMBER    DEC  12

Example: DTIME and DATETIME

DATA LIST FIXED /VAR1 1-14 (DTIME) VAR2 18-42 (DATETIME).
BEGIN DATA
20 8:3           20-6-90 8:3
20:8:03:46       20/JUN/1990 8:03:46
20 08 03 46.75   20 June, 2001 08 03 46.75
END DATA.
LIST.
  • DTIME and DATETIME read and write time intervals.
  • The decimal point explicitly coded in the input data for fractional seconds.
  • The DTIME format allows a – or + sign in the data value to indicate a time interval before or after a point in time.
  • Internally, values for a DTIME variable are stored as the number of seconds of the time interval, while those for a DATETIME variable are stored as the number of seconds from 0 hours, 0 minutes, and 0 seconds of Oct. 14, 1582.

The LIST output from these commands is shown in the following figure.

Figure 5. Output illustrating DTIME and DATETIME formats
          VAR1                      VAR2

   20 08:03:00      20-JUN-1990 08:03:00
   20 08:03:46      20-JUN-1990 08:03:46
   20 08:03:46      20-JUN-2001 08:03:46