Re: split a number to Date format
- To: mathgroup at smc.vnet.net
- Subject: [mg124269] Re: split a number to Date format
- From: "Dr. Wolfgang Hintze" <weh at snafu.de>
- Date: Sat, 14 Jan 2012 17:17:41 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <jercf9$1aa$1@smc.vnet.net>
"Derek Martin" <cdmartin at me.com> schrieb im Newsbeitrag news:jercf9$1aa$1 at smc.vnet.net... >I have experimental data in spreadsheet format. The first column is a >time stamp in the format 111205020000. > If I could parse or split the number 111205020000 into > {11,12,05,02,00,00} and replace the first 11 with 2011, the Date > commands would work fine. I can do the replacing, but am having > difficulty seeing how to split the number into {11,12,05,02,00,00}. > > DateString[{2011, 12, 05, 02, 00, 00}] gives > "Mon 5 Dec 2011 02:00:00" > > Any help to convert my number to the right Date format would be > appreciated. I am using Mathematica 8. > > Thanks in Advance > Derek > Not very elegant, but it works In[2]:= dn = 111205020000 Out[2]= 111205020000 In[3]:= ds = StringJoin["20", ToString[dn]]; (Prepend[Table[StringTake[#1, {i, i + 1}], {i, 5, StringLength[#1] - 1, 2}], StringTake[#1, {1, 4}]]& )[ds] Out[3]= {"2011", "12", "05", "02", "00", "00"} Regards, Wolfgang