Date to Age


I have date of birth (variable "DOB") in this format: 8/12/1995.
I need to calculate age.

I keep reading all these examples that include things like "," "DATE.MDY," etc. but when I try to adapt the syntax to my data it never runs correctly.

Could someone give me an example of what my syntax should look like? I know there needs to be another reference date used - like the current date ($TIME) or another date variable in my data (e.g. I have a variable about graduation date that is formatted the same way as DOB) in order to calculate age. I don't care what reference date is used, I just want to know how to do this in general.

SPSS has a date and time wizard for precisely this type of problem. Go to Transform -> Date and Time Wizard. You'll be able to work out the rest from there.
Indeed. If you'd used the wizard you would have seen that there is an option to paste the syntax used to calculate the variable into a new window or you could have copied it from the output once it had run.

Anyhow, the function you want is 'datediff':

compute age = datediff($time, dob, "years").