Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2007
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

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

Search the Archive

Re: Conversion back to excel date format

  • To: mathgroup at smc.vnet.net
  • Subject: [mg73130] Re: Conversion back to excel date format
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Sun, 4 Feb 2007 07:05:16 -0500 (EST)
  • Organization: The Open University, Milton Keynes, UK
  • References: <eq1il6$2vi$1@smc.vnet.net>

Clifford Martin wrote:
> I have a list of numbers I've calculated. The last element in the list is a date in Mathematica format. I needed it to be in that format to use the Miscellaneous`Calendar functions. When I'm done I output the list (of lists) to a txt file and read it into Excel. (The guy I'm working with can only use Excel).
> 
> So the list looks something like this for 1 row
> 
> {{a,b,c,d,e,f,g,{2004,11,15}}} where a,b,c,d,e,f,g are numbers I've calculated. I'd like to convert the last element (the date) into a date format compatible with Excel such as 11/15/2004 before I export the data. Any suggestions?
> 
> Thanks in advance.
> 
> Cliff
> 
Hi Cliff,

I do not have Excel on this computer, but I believe that if you convert 
the Mathematica dates into text strings, Excel should handle them 
correctly. You could try,

In[1]:=
data = {{a, b, c, d, e, f, g, {2004, 11, 15}},
{h, b, c, d, e, f, g, {2005, 11, 15}},
{i, b, c, d, e, f, g, {2003, 11, 15}},
{j, b, c, d, e, f, g, {2004, 12, 12}}};

In[2]:=
data /. {y_, m_, d_} :> StringJoin[ToString[m], "/", ToString[d], "/", 
ToString[y]]

Out[2]=
{{a,b,c,d,e,f,g,11/15/2004},
{h,b,c,d,e,f,g,11/15/2005},
{i,b,c,d,e,f,g,11/15/2003},
{j,b,c,d,e,f,g,12/12/2004}}

Note that the above transformation rule might not be the most efficient 
if the list is large. But a least you can check with Excel the text 
string transformation works.

Regards,
Jean-Marc


  • Prev by Date: Re: Boole does not work with symbolic limits in Integrate
  • Next by Date: Re: record intermediate steps
  • Previous by thread: Re: Conversion back to excel date format
  • Next by thread: Re: Conversion back to excel date format