MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: split a number to Date format


split1[x_] := ReplacePart[#, 1 -> First[#] + 2000] &[
  FromDigits /@ Partition[IntegerDigits[x], 2]]

split1[111205020000]

{2011, 12, 5, 2, 0, 0}

split2[x_] := MapAt[2000 + # &,
  FromDigits /@ Partition[IntegerDigits[x], 2], 1]

split2[111205020000]

{2011, 12, 5, 2, 0, 0}


Bob Hanlon


On Sat, Jan 14, 2012 at 2:54 AM, Derek Martin <cdmartin at me.com> wrote:
> 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
>



  • Prev by Date: Re: Cross reference
  • Next by Date: Re: split a number to Date format
  • Previous by thread: Re: split a number to Date format
  • Next by thread: Re: split a number to Date format