SPSS date variables may seem a bit puzzling at first. However, getting things done fast and accurately with SPSS date variables is not hard at all if you understand some basics. This tutorial will walk you through. You can follow along by downloading and opening hospital.sav.

SPSS Date Variables - What Are They?
First of all, SPSS date variables are numeric variables; their actual values are just numbers. More precisely, the numbers they hold are the number of seconds between the year 1582 and the start (midnight) of a given date. Realizing that it's these underlying values that date calculations act upon renders SPSS date logic straightforward.
Second, these huge numbers are usually shown as normal dates by setting their format to one of SPSS' main date formats. We'll outline some of those in the table below.
SPSS Date Formats
As we just mentioned, SPSS date values are always numbers of seconds. You can choose several formats for displaying them as actual dates. Some main options are given in the table below.
Variable Type | Format family | Format (example) | Shown as |
---|---|---|---|
Numeric | Date | Date11 | 19-jan-2013 |
Numeric | Edate (= European date) | Edate10 | 19.01.2013 |
Numeric | Adate (= American date) | Adate10 | 01/19/2013 |
Numeric | Sdate (= Sortable date) | Sdate10 | 2013/01/19 |
As suggested by this table, we recommend that you always display years as 4 digits instead of 2.A reason for this is explained in Two Digit Year in String - Cautionary Note.
SPSS Date Variables - Example
The aforementioned points may sound rather abstract so let's demonstrate them on our data. It contains one proper date variable, entry_date. We'll take a look at its actual values by giving it an an f format. Running the following line of syntax does just that. formats entry_date(f1).

The date values now look very differently in data view. However, they are still the exact same values that we had a few seconds ago; they're just displayed differently. We'll now show them as dates by running formats entry_date(sdate10). After doing so, the actual date values look like date values again. Again, keep in mind that actual values still haven't changed in any way.
SPSS Date Calculations
So why bother about the huge numbers that underlie SPSS date values? The reason is that its these values that SPSS date functions act upon.
When we understand that date values are really numbers of seconds, it becomes very easy to add, say, one day to date values. Note that one day is 60 (seconds) * 60 (minutes) * 24 (hours) = 86400 seconds. Now watch what happens when we simply add 86400 to our date variable by running the syntax below.
compute entry_date = entry_date + 86400.
exe.
Indeed, exactly one day has been added to all values. However, adding a month is more complicated because different months hold different numbers of days.
For such cases SPSS has some specialized date functions that render such operations a piece of cake. The next tutorial will walk you through the most important ones.
THIS TUTORIAL HAS 8 COMMENTS:
By Karen on November 9th, 2016
How do I convert a date 01NOV2016 that is string 9 to a date or numeric type?
By Ruben Geert van den Berg on November 10th, 2016
Hi Karen!
There's no easy solution for handling that date format because day, month and year aren't separated by any character. I'd concatenate the D, M, Y substrings and add dashes between them into a new string variable.
Then convert that string variable to a date variable with ALTER TYPE and check for system missing values.
Ok, it's really not as difficult as it sounds. Please try the syntax example at Convert String with Dates to SPSS Date Variable. If that doesn't get the job done, let me know, ok?
By Nicola on December 11th, 2018
Hi Ruben! Firstly, thank you so much for your tutorial and your useful answers! I want to select only cases in which date A is before the date B. How could I do it?
By Ruben Geert van den Berg on December 11th, 2018
Hi Nicola!
Try
SELECT IF(date_a < date_b).
Or if you want to play it safe
COMPUTE keep = 0.
IF(date_a < date_b) keep = 1.
EXECUTE.
(Visually inspect cases here... Perhaps run a FREQUENCIES... Go get some more coffee... Take a nap... and... then...)
SELECT IF(keep = 1).
or even shorter
SELECT IF(keep).
By Teodora Koleva on October 23rd, 2019
I have a problen in SPSS and I hope you can help me.
I uploaded the .xlsx file to SPSS. In the Variable View screen, I changed the data type from String to Numeric. After making it, in Data View screen, I found that entries for that variable have been deleted completely. How can I fix it?