Re: Separate shifts within date time variable
Posted by
PRogman on
URL: http://spssx-discussion.165.s1.nabble.com/Separate-shifts-within-date-time-variable-tp5740995p5740996.html
I don't have SPSS available on this computer. If you want 4 groups in the same variable, change 'Shift = 1 +' to 'Status = 3 +'.
* untested *.
if (orderdatetime ge Date.DMY(05,06,2020))
Shift = 1 + ((XDATE.TIME(orderdatetime) lt CTIME.HOURS(11)) AND (XDATE.TIME(orderdatetime) gt CTIME.HOURS(23))).
execute.
parisec wrote
Hi all,
I have data where i need to compute 4 separate groups based on dates and times of when an order was placed.
The first 2 groups are easy since they are based just on date of order.
compute status = $sysmis.
if orderdatetime lt Date.DMY(30,11,2019) status = 0.
if orderdatetime ge Date.DMY(01,12,2019) and orderdatetime le Date.DMY(04,06,2020) status = 1.
The next 2 groups have the same date range (Date.DMY ge (05,06,2020)) but they needed to be divided into Shift 1 and Shift 2:
Shift 1 = 1100 - 2300
Shift 2 = 2301 - 1059
Do I first need to extract out the time from the date so that i have both an orderdate and ordertime?
Or is there a way i can do this with the current orderdatetime variable?
Thanks much.
Carol