|
Hello all,
I wonder how to convert a string variable of the following kind into a date format:
2008-11-17 10:49:46 2008-11-17 11:14:43 2008-11-17 11:19:34 ...
I tried the function DATETIMEw.d but it didn't work.
Thanks for any help!
Mario
Mario Giesel
Munich, Germany |
|
Datetime isn’t a function. It’s a format,
and unfortunately your date doesn’t fit the rather strict rules for datetime
format, nor does the Date/Time Wizard cover your situation. Try something like
this: data list list (",") /stringdate
(a20). begin data 2008-11-17 10:49:46 2008-11-17 11:14:43 2008-11-17 11:19:34 end data. compute #i=index(stringdate, "
"). compute #date=number(substr(stringdate, 1,
#i-1), sdate10). compute #hour=number(substr(stringdate,
#i+1), time8). compute datetimevar=#date+#hour. format datetimevar (datetime20). list. From: SPSSX(r)
Discussion [mailto:[hidden email]] On
Behalf Of Mario Giesel Hello all, I wonder how to convert a string variable of the
following kind into a date format:
... I tried the function DATETIMEw.d
but
it didn't work. Thanks for any help! Mario |
|
In reply to this post by Mario Giesel
Open a new instance of SPSS.� Copy the syntax below to a syntax file.
Click <run>. Click <all>.
data list list/thedate (sdate10)thetime(time8). begin data 2008-11-17 10:49:46� � � � � � � � � 2008-11-17 11:14:43� � � � � � � � � 2008-11-17 11:19:34 end data. numeric wholething(datetime20). compute wholething = thedate+thetime. list. Art Kendall Social Research Consultants Mario Giesel wrote:
Art Kendall
Social Research Consultants |
|
Thanks to Ergul, Oliver, and Art for their contributions!
I used Arts solution which was easiest and worked fine. Now I can deal with similar kinds of date problems in the future.
Good luck
Mario
Von: Art Kendall <[hidden email]> An: Mario Giesel <[hidden email]> CC: [hidden email] Gesendet: Dienstag, den 17. Februar 2009, 20:37:14 Uhr Betreff: Re: Reading a string date Open a new instance of SPSS. Copy the syntax below to a syntax file. Click <run>. Click <all>. data list list/thedate (sdate10)thetime(time8). begin data 2008-11-17 10:49:46 2008-11-17 11:14:43 2008-11-17 11:19:34 end data. numeric wholething(datetime20). compute wholething = thedate+thetime. list. Art Kendall Social Research Consultants Mario Giesel wrote:
Mario Giesel
Munich, Germany |
| Free forum by Nabble | Edit this page |
