|
Greetings,
I have a date/time field containing the following: 14-JUN-2009 19:14:00 14-JUN-2009 22:49:00 14-JUN-2009 18:35:00 14-JUN-2009 18:42:00 14-JUN-2009 21:33:00 15-JUN-2009 01:10:00 14-JUN-2009 23:53:00 I need to extract just the time portion out of this so that it looks like this: 19:14:00 22:49:00 18:35:00 18:42:00 21:33:00 01:10:00 23:53:00 I don't necessary need to retain the date portion so tried manually changing the field type to give me hh:mm:ss but was not successful. Anyone have syntax? Thanks and happy long weekend. Carol ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
|
At 06:10 PM 11/28/2009, Parise, Carol A. wrote:
I have a date/time field containing the following:... How about (untested), NUMERIC Time (TIME8). COMPUTE Time = XDATE.TIME(DateTime). I tried manually changing the field type to give me hh:mm:ss but was not successful. Right. That just changes how the value is displayed, not the value itself. ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
|
In reply to this post by parisec
Perhaps a solution has already been found, but a text file ('dates.txt'
containing your test values) and the following syntax worked when read in as two separate variables... GET DATA /TYPE=TXT /FILE = 'dates.txt' /DELCASE = LINE /DELIMITERS = " " /ARRANGEMENT = DELIMITED /VARIABLES = PART1 DATE10 PART2 TIME. Regards, Bob Walker Surveys & Forecasts, LLC www.safllc.com -----Original Message----- From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of Parise, Carol A. Sent: Saturday, November 28, 2009 6:10 PM To: [hidden email] Subject: extract time from date/time field Greetings, I have a date/time field containing the following: 14-JUN-2009 19:14:00 14-JUN-2009 22:49:00 14-JUN-2009 18:35:00 14-JUN-2009 18:42:00 14-JUN-2009 21:33:00 15-JUN-2009 01:10:00 14-JUN-2009 23:53:00 I need to extract just the time portion out of this so that it looks like this: 19:14:00 22:49:00 18:35:00 18:42:00 21:33:00 01:10:00 23:53:00 I don't necessary need to retain the date portion so tried manually changing the field type to give me hh:mm:ss but was not successful. Anyone have syntax? Thanks and happy long weekend. Carol ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
|
In reply to this post by parisec
Dear Carol,
I would try the following: COMMENT this syntax will take the date_time variable (content like this 14- JUN-2009 19:14:00 and in the date and time format) and deduct the date element from it to leave only the time . COMPUTE time_only=date_time - (XDATE.DATE(date_time)). FORMATS time_only (time) . EXECUTE. It seems to work. Jacqueline http://www.uk.sagepub.com/booksProdDesc.nav?prodId=Book229167& On Tue, 1 Dec 2009 14:57:54 -0500, Bob Walker <[hidden email]> wrote: >Perhaps a solution has already been found, but a text file ('dates.txt' >containing your test values) and the following syntax worked when read in as >two separate variables... > >GET DATA /TYPE=TXT /FILE = 'dates.txt' /DELCASE = LINE /DELIMITERS = " " > /ARRANGEMENT = DELIMITED /VARIABLES = PART1 DATE10 PART2 TIME. > >Regards, > >Bob Walker >Surveys & Forecasts, LLC >www.safllc.com > >-----Original Message----- >From: SPSSX(r) Discussion [mailto:[hidden email]] On Behalf Of >Parise, Carol A. >Sent: Saturday, November 28, 2009 6:10 PM >To: [hidden email] >Subject: extract time from date/time field > >Greetings, > > > >I have a date/time field containing the following: > > > >14-JUN-2009 19:14:00 >14-JUN-2009 22:49:00 >14-JUN-2009 18:35:00 >14-JUN-2009 18:42:00 >14-JUN-2009 21:33:00 >15-JUN-2009 01:10:00 >14-JUN-2009 23:53:00 > > > > > >I need to extract just the time portion out of this so that it looks like >this: > >19:14:00 >22:49:00 >18:35:00 >18:42:00 >21:33:00 >01:10:00 >23:53:00 > > > > > >I don't necessary need to retain the date portion so tried manually >the field type to give me hh:mm:ss but was not successful. > > > >Anyone have syntax? > > > >Thanks and happy long weekend. > >Carol > >===================== >To manage your subscription to SPSSX-L, send a message to >[hidden email] (not to SPSSX-L), with no body text except the >command. To leave the list, send the command >SIGNOFF SPSSX-L >For a list of commands to manage subscriptions, send the command >INFO REFCARD > >===================== >To manage your subscription to SPSSX-L, send a message to >[hidden email] (not to SPSSX-L), with no body text except the >command. To leave the list, send the command >SIGNOFF SPSSX-L >For a list of commands to manage subscriptions, send the command >INFO REFCARD ===================== To manage your subscription to SPSSX-L, send a message to [hidden email] (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD |
| Free forum by Nabble | Edit this page |
