1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
*Q: I import dates from excel and obtain 4 or 5 digits numbers, how can I get dates in SPSS?

*A: You are getting the number of days since 31/12/1899 (1 means 1/1/1900)
	If you go in excel and change the format of the dates 
	to a number format, you will see the same 5 digits numbers you obtain in SPSS.
* rlevesque@videotron.ca.

*To convert the 5 digits numbers to SPSS dates, try this.
DATA LIST LIST /var1(F8.0) var2(A6).
BEGIN DATA
1 	"1"
36604 	"36604"
25000 	"25000"
END DATA.
LIST.

COMPUTE date1=date.dmy(1,1,1900)+ (var1-2)*60*60*24.
COMPUTE date2=date.dmy(1,1,1900)+ (NUMBER(var2,F8.0)-2)*60*60*24.
FORMATS date1 date2 (ADATE12).
LIST.

*where var1 is the variable containing the 5 digits your are getting from Excel.

************************************************************************.

* if you want the date to be in a string variable.
STRING z(A11).
COMPUTE z=STRING(date2,ADATE11).