LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (October 2009)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Thu, 8 Oct 2009 06:23:59 -0700
Reply-To:   Bruce Weaver <bruce.weaver@hotmail.com>
Sender:   "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:   Bruce Weaver <bruce.weaver@hotmail.com>
Subject:   Re: SPSS date transformation help
In-Reply-To:   <F5451060901E49E3880B00C9D33276EF@yourg2asvv4l2m>
Content-Type:   text/plain; charset=us-ascii

John F Hall-2 wrote: > > Jazgul > > Bit outside my field I'm afraid, and it will take me too long to find out. > Someone on the list will know. ViAnn Beadle, Jon Peck and Bruce Weaver > usually give knowledgable replies. There was something a while back on > converting seconds to years or vice versa, something like that, but I've > deleted my copies > > John > ----- Original Message ----- > From: Jazgul Ismailova > To: johnfhall@orange.fr > Sent: Thursday, October 08, 2009 8:55 AM > Subject: SPSS date transfromation help > > > Hello John, > > Could you kindly help me wit hthe following task. > > I have a date in the following format: > 05-OCT-2009 09:12:28 > 05-OCT-2009 11:18:12 > 05-OCT-2009 12:39:45 > 05-OCT-2009 15:09:49 > 05-OCT-2009 15:45:22 > 05-OCT-2009 19:26:40 > 05-OCT-2009 20:14:04 > > What I need is this > > 051009 > 051009 > 051009 > 051009 > 051009 > 051009 > 051009 > I come up with the script: > > STRING rdate (A6). > compute rdate= concat (string (xdate.mday (intend), f2.0), lpad (ltrim > (string (xdate.month (intend), f2.0)), 2, "0"), substr (string (xdate.year > (intend), f4.0), 3, 2)). > EXE. > > But then I get just: > 51009 > 51009 > 51009 > 51009 > 51009 > 51009 > 51009 > > How can I add 0s in the day? So that it is 6 digit? > > > Thank you in advance, > > Jazgul > >

How about this? DATEVAR refers to your original date-time variable.

format datevar (edate9). string newdatestr (a8). compute newdatestr = replace(string(datevar,edate9),".",""). exe.

Formatting as EDATE9 changes the dates to 05.10.09. The COMPUTE statement converts that date variable to a string, then replaces "." with "".

----- -- Bruce Weaver bweaver@lakeheadu.ca http://sites.google.com/a/lakeheadu.ca/bweaver/ "When all else fails, RTFM."

NOTE: My Hotmail account is not monitored regularly. To send me an e-mail, please use the address shown above. -- View this message in context: http://www.nabble.com/Re%3A-SPSS-date-transformation-help-tp25799767p25802982.html Sent from the SPSSX Discussion mailing list archive at Nabble.com.

===================== To manage your subscription to SPSSX-L, send a message to LISTSERV@LISTSERV.UGA.EDU (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


Back to: Top of message | Previous page | Main SPSSX-L page