SPSS Statistics

 View Only
  • 1.  Milliseconds to Datetime

    Posted Thu May 11, 2023 09:32 AM

    Dear all,

    I am having trouble converting a time value (milliseconds since 01/01/1070) to a meaningful date + time (dd-mm-yyy hh:mm). 

    An example value (Milliseconds): x = 1631184480216

    The newer versions of SPSS already have 1970 as a base value, right?

    In Excel the following formula works: = (H8 / 86400000) + DATUM(1970;1;1)

    In SPSS I tried this: 

    COMPUTE x2 = (x / 86400000).
    EXECUTE.

    alter type x2(datetime17).
    EXECUTE.

    However, x2 is a decimal number that SPSS cannot convert to a date. If I convert the original variable x (alter type x(datetime17)) the result is: 17-Dec-53272 00:03, which is a completely unrealistic date. 

    Does anyone know a solution to this problem?

    Thanks in advance!



    ------------------------------
    Sabrina Eutebach
    ------------------------------


  • 2.  RE: Milliseconds to Datetime

    IBM Champion
    Posted Thu May 11, 2023 09:39 AM
    No, the base for date/time in Statistcs is 1582, the origin in most countries of the Gregorian calendar.  Dates are in units of seconds but are to full floating point precision.  You can use the Date.Mdy function to get the value for 1/1/1970 and then add the millisecond value from then or use other date/time functions.

    --