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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

62 Universals<br />

Example<br />

DATA LIST RECORDS=2<br />

/TIME 1-8 (TIME) DTIME 10-19 (DTIME) DATE 21-29 (DATE)<br />

ADATE 31-38 (ADATE)<br />

/DATTIME1 1-18 (DATETIME) DATTIME2 20-37 (DATETIME).<br />

BEGIN DATA<br />

1:10:15 1 0:25:10 13-8-90 10/21/90<br />

28-OCT-90 9:15:17 29/OCT/90 10:30:22<br />

END DATA.<br />

COMPUTE ADDTIME=TIME+DTIME.<br />

COMPUTE DATEDIF1=ADATE-DATE.<br />

COMPUTE DATEDIF2=DATTIME2-DATTIME1.<br />

COMPUTE DATETIME=DATTIME2+DTIME.<br />

LIST VARIABLES=ADDTIME DATEDIF1 DATEDIF2 DATETIME.<br />

FORMATS ADDTIME DATEDIF2 (TIME15) DATEDIF1 (DTIME15)<br />

DATETIME (DATETIME25).<br />

LIST VARIABLES=ADDTIME DATEDIF1 DATEDIF2 DATETIME.<br />

The results of these commands are shown in Figure 20.<br />

Figure 20 Results of arithmetic operations with date and time variables<br />

ADDTIME DATEDIF1 DATEDIF2 DATETIME<br />

25:35:25 69 00:00:00 25:15:05 30-OCT-1990 10:55:32<br />

Date and Time Functions<br />

Date and time functions provide aggregation, conversion, and extraction routines for dates<br />

and time intervals. Each function transforms an expression consisting of one or more<br />

arguments. Arguments can be complex expressions, variable names, or constants. Date and<br />

time expressions and variables are legitimate arguments.<br />

All date functions that accept the argument of day—for example, DATE.DMY(d,m,y),<br />

DATE.MDY(m,d,y), and DATE.YRDAY(y,d)—check the validity of the argument. The value for<br />

day must be an integer between 1 and 31. If an invalid value is encountered, a warning is<br />

displayed and the value is set to system-missing. However, if the day value is invalid for a<br />

particular month—for example, 31 in September, April, June, and November or 29 through<br />

31 for February in non-leap years—the resulting date is placed in the next month (for example,<br />

if you enter 2 for MONTH, 31 for DAY, and 91 for YEAR, the result becomes 03/02/91).

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

Saved successfully!

Ooh no, something went wrong!