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