6.7.4.5 Time and Date Formats

In PSPP, a time is an interval. The time formats translate between human-friendly descriptions of time intervals and PSPP’s internal representation of time intervals, which is simply the number of seconds in the interval. PSPP has three time formats:

Time FormatTemplateExample
MTIMEMM:SS.ss91:17.01
TIMEhh:MM:SS.ss01:31:17.01
DTIMEDD HH:MM:SS.ss00 04:31:17.01

A date is a moment in the past or the future. Internally, PSPP represents a date as the number of seconds since the epoch, midnight, Oct. 14, 1582. The date formats translate between human-readable dates and PSPP’s numeric representation of dates and times. PSPP has several date formats:

Date FormatTemplateExample
DATEdd-mmm-yyyy01-OCT-1978
ADATEmm/dd/yyyy10/01/1978
EDATEdd.mm.yyyy01.10.1978
JDATEyyyyjjj1978274
SDATEyyyy/mm/dd1978/10/01
QYRq Q yyyy3 Q 1978
MOYRmmm yyyyOCT 1978
WKYRww WK yyyy40 WK 1978
DATETIMEdd-mmm-yyyy HH:MM:SS.ss01-OCT-1978 04:31:17.01
YMDHMSyyyy-mm-dd HH:MM:SS.ss1978-01-OCT 04:31:17.01

The templates in the preceding tables describe how the time and date formats are input and output:

dd

Day of month, from 1 to 31. Always output as two digits.

mm
mmm

Month. In output, mm is output as two digits, mmm as the first three letters of an English month name (January, February, …). In input, both of these formats, plus Roman numerals, are accepted.

yyyy

Year. In output, DATETIME and YMDHMS always produce 4-digit years; other formats can produce a 2- or 4-digit year. The century assumed for 2-digit years depends on the EPOCH setting (see SET EPOCH). In output, a year outside the epoch causes the whole field to be filled with asterisks (‘*’).

jjj

Day of year (Julian day), from 1 to 366. This is exactly three digits giving the count of days from the start of the year. January 1 is considered day 1.

q

Quarter of year, from 1 to 4. Quarters start on January 1, April 1, July 1, and October 1.

ww

Week of year, from 1 to 53. Output as exactly two digits. January 1 is the first day of week 1.

DD

Count of days, which may be positive or negative. Output as at least two digits.

hh

Count of hours, which may be positive or negative. Output as at least two digits.

HH

Hour of day, from 0 to 23. Output as exactly two digits.

MM

In MTIME, count of minutes, which may be positive or negative. Output as at least two digits.

In other formats, minute of hour, from 0 to 59. Output as exactly two digits.

SS.ss

Seconds within minute, from 0 to 59. The integer part is output as exactly two digits. On output, seconds and fractional seconds may or may not be included, depending on field width and decimal places. On input, seconds and fractional seconds are optional. The DECIMAL setting controls the character accepted and displayed as the decimal point (see SET DECIMAL).

For output, the date and time formats use the delimiters indicated in the table. For input, date components may be separated by spaces or by one of the characters ‘-’, ‘/’, ‘.’, or ‘,’, and time components may be separated by spaces or ‘:’. On input, the ‘Q’ separating quarter from year and the ‘WK’ separating week from year may be uppercase or lowercase, and the spaces around them are optional.

On input, all time and date formats accept any amount of leading and trailing white space.

The maximum width for time and date formats is 40 columns. Minimum input and output width for each of the time and date formats is shown below:

FormatMin. Input WidthMin. Output WidthOption
DATE894-digit year
ADATE884-digit year
EDATE884-digit year
JDATE554-digit year
SDATE884-digit year
QYR464-digit year
MOYR664-digit year
WKYR684-digit year
DATETIME1717seconds
YMDHMS1216seconds
MTIME45
TIME55seconds
DTIME88seconds

In the table, “Option” describes what increased output width enables:

4-digit year

A field 2 columns wider than the minimum includes a 4-digit year. (DATETIME and YMDHMS formats always include a 4-digit year.)

seconds

A field 3 columns wider than the minimum includes seconds as well as minutes. A field 5 columns wider than minimum, or more, can also include a decimal point and fractional seconds (but no more than allowed by the format’s decimal places).

For the time and date formats, the default output format is the same as the input format, except that PSPP increases the field width, if necessary, to the minimum allowed for output.

Time or dates narrower than the field width are right-justified within the field.

When a time or date exceeds the field width, characters are trimmed from the end until it fits. This can occur in an unusual situation, e.g. with a year greater than 9999 (which adds an extra digit), or for a negative value on MTIME, TIME, or DTIME (which adds a leading minus sign).

The system-missing value is output as a period at the right end of the field.