recoding to datetime syntax

#1
I am trying to recode a variable. My original survey asked participants to enter a time of day they do an activity on the half hour, ranging from not applicable (coded as 1) to 12:00am on day 1 (coded as “2”) to 5:30am the following day (day 2; coded as “61”). I asked participants to enter acivity times for 7 consecutive days, with the last times going into 5:30am on day 8.

I am trying to recode these variables (1 to 61 for each day) to what I believe is called datetime syntax, so that for “day 1,” what SPSS currently coded as “2” will become 12:00am on Day 1 (or on an arbitrary day), and so that variable 58, for instance, would be coded as 4:00am on day 2.

I have struggled with how to recode these so that I can then manipulate the dates and times to calculate individual and group averages, activity durations, and the like. I am fine with picking arbitrary “dates” for days 1-8, but I am having trouble with the correct recoding syntax for datetime. Any help would be much appreciated!

-grateful grad student
 
#2
This should do what you need:

Code:
** Generate some time codes.

input program.
loop id = 1 to 100.
compute timecode = trunc(rv.uniform(1,62)).
end case.
end loop.
end file.
end input program.

** Convert time codes to date time format.

do if (timecode ne 1).
compute #x = ((timecode -2) / 2)*60 + (60*24).
compute  newtime=time.hms(0,  #x, 0).
end if.
formats  newtime (dtime9).
exe.