Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Date Formatting
Replies: 5   Last Post: Dec 9, 2012 11:33 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
bigchap86

Posts: 3
Registered: 12/8/12
Re: Date Formatting
Posted: Dec 9, 2012 11:31 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Great, thanks guys.

On Sat, Dec 8, 2012 at 11:05 AM, James Stein <mathgroup@stein.org> wrote:

> 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!
> >

>



--
Ross Daniel Chapman
Ross.D.Chapman@gmail.com
(608) 206-5967





Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.