Reputation: 183
In my dataset is birthdate a string. It looks like that:
2003-03-01 00:00:00
I need that it to look like that:
2003.03.01
I have tried to change it in variable view and it did not worked out. Could you please help me to find a solution?
Upvotes: 2
Views: 90
Reputation: 11310
I don't know if there is a way to get SPSS to recognize the original date format in your string (anyone?) - so this is a workaround. The following command takes each element of the date from the string, turns it into a number, and inputs all three elements in a date creation command:
COMPUTE NewDateVar = DATE.DMY(number(char.substr(yourvar,9,2),f4),
number(char.substr(yourvar,6,2),f2),
number(char.substr(yourvar,1,4),f2)).
FORMATS NewDateVar (SDATE10).
EXECUTE.
Upvotes: 1