27.03.2013 Views

SPSS® 12.0 Command Syntax Reference

SPSS® 12.0 Command Syntax Reference

SPSS® 12.0 Command Syntax Reference

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Date and Time 61<br />

• A time interval is a floating-point number representing the number of seconds in a time<br />

period, for example, an hour, minute, or day. For example, the value representing 5.5 days<br />

is 475,200; the value representing the time interval 14:08:17 is 50,897.<br />

• QYR, MOYR, and WKYR variables are stored as midnight of the first day of the respective<br />

quarter, month, and week of the year. Therefore, 1 Q 90, 1/90, and 1 WK 90 are all equivalents<br />

of January 1, 1990 0:0:00. See “Date and Time Functions” on p. 62 for information<br />

on how to determine the quarter, month, or week of a year for a certain date.<br />

• WKDAY variables are stored as 1 to 7, and MONTH variables as 1 to 12. For information on<br />

how to determine the day of the week or the month of the year for a certain date, see “Date<br />

and Time Functions” on p. 62.<br />

• Both dates and time intervals can be used in arithmetic expressions. The results are stored<br />

as the number of seconds or days (see Table 8).<br />

• Do not mix time variables (TIME and DTIME) with date variables (DATE, ADATE, EDATE,<br />

and so on) in computations. Since date variables have an implicit time value of 00:00:00,<br />

calculations involving time values that are not multiples of a whole day (for example, 24<br />

hours, 0 minutes, 0 seconds) will yield unreliable results.<br />

• Mixing a DATETIME variable with a date variable may yield an unreliable result.<br />

Operations involving date variables are accurate only to the days. To avoid possible<br />

misinterpretation, use the DTIME format and ignore the hours and minutes portion of the<br />

resulting value.<br />

You can perform virtually any arithmetic operation with them. Of course, not all of these<br />

operations are particularly useful. You can calculate the number of days between two dates<br />

by subtracting one date from the other—but adding two dates does not produce a very meaningful<br />

result.<br />

By default, any new numeric variables you compute are displayed in F format. In the case<br />

of calculations involving time and date variables, this means that the default output is expressed<br />

as a number of seconds or days. Use the FORMATS (or PRINT FORMATS) command<br />

to specify an appropriate format for the computed variable. Table 8 shows the recommended<br />

output formats for some of the calculations possible with date and time variables.<br />

Table 8 Recommended output formats for date and time calculations<br />

Arithmetic operation Result Recommended output format<br />

time ± time *<br />

time TIME, DTIME<br />

date – date †<br />

time DTIME<br />

DATETIME – DATETIME time TIME, DTIME<br />

DATETIME ± time date DATETIME<br />

* Including TIME and DTIME formats.<br />

† Including DATE, ADATE, EDATE, JDATE, and SDATE formats.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!