Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #12699

Re: Date Formatting

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!news-out.readnews.com!transit3.readnews.com!newspump.sol.net!posts.news.twtelecom.net!nnrp3.twtelecom.net!not-for-mail
From James Stein <mathgroup@stein.org>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Date Formatting
Date Sun, 9 Dec 2012 15:57:38 +0000 (UTC)
Sender steve@smc.vnet.net
Approved Steven M. Christensen <steve@smc.vnet.net>, Moderator
Message-ID <ka2cdi$7ff$1@smc.vnet.net> (permalink)
References <20121208063016.AD08D6929@smc.vnet.net>
Lines 36
Organization Time-Warner Telecom
NNTP-Posting-Date 09 Dec 2012 16:00:09 GMT
NNTP-Posting-Host e6fd405f.news.twtelecom.net
X-Trace DXC=XEniXf7h@JKhc=@:g6e6dKC_A=>8kQj6MY;@_o827nGCG`=2W4YiB5IEFiONJ7[GoF\Ka;3nk]dJF
X-Complaints-To abuse@twtelecom.net
Xref csiph.com comp.soft-sys.math.mathematica:12699

Show key headers only | View raw


Here is a simple, if ugly, routine to reformat Excel dates to
Mathematica's DateLists:

ClearAll [ reformat ];
SetAttributes [ reformat, Listable ];
reformat [ excelDate_String ] := Module [ {m, d, y},
   {m, d, y} = StringSplit[excelDate, "-"];
   m = Switch[m,
     "Jan", 1, "Feb", 2, "Mar", 3, "Apr", 4, "May", 5, "Jun", 6,
     "Jly", 7, "Aug", 8, "Sep", 9, "Oct", 10, "Nov", 11, "Dec", 12, _,
      Abort[]];
   {y, m, d} // ToExpression
   ];
reformat [ { "Mar-15-2010", "Apr-15-2011", "Dec-25-2012" } ]
reformat [ "Foo-13-1999" ]


On Fri, Dec 7, 2012 at 10:30 PM, bigchap86 <ross.d.chapman@gmail.com> wrote:
>
> Hello all,
>
> Quick question re: date formatting:
>
> So I've imported a data set externally from Excel with the intent to try to plot a time series graph. Unfortunately, the dates have come in the following format:
>
> Mar-28-2008
>
> When using the DateListPlot function, Mathematica does recognize this date format as a date, as long as you put each data point into the formula individually, and put quotations around them, e.g.:
>
> DataListPlot[{1,2},{"Mar-28-2008", "Apr-03-2009"}] works as a function, BUT if you set {"Mar-28-2008", "Apr-03-2009"}=dates, and use DataListPlot[{1,2},{dates}], it doesn't work.
>
> Anyone have ideas on how to reformat the dates so it works? It appears that there's some sort of disconnect when the dates are entered into a series.
>
> Thanks!
>

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: Date Formatting James Stein <mathgroup@stein.org> - 2012-12-09 15:57 +0000

csiph-web