Re: hold question
- To: mathgroup at smc.vnet.net
- Subject: [mg132337] Re: hold question
- From: Alexei Boulbitch <Alexei.Boulbitch at iee.lu>
- Date: Wed, 12 Feb 2014 05:13:30 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- Delivered-to: l-mathgroup@wolfram.com
- Delivered-to: mathgroup-outx@smc.vnet.net
- Delivered-to: mathgroup-newsendx@smc.vnet.net
Dear Group: Manipulating and importing/exporting dates is always a pain in the neck, in any of the languages I am aware of. Mathematica has functions to work around many of these issues, and I was actually able to complete the task I was involved in, but even then there is an issue I obviously do not understand. Say I have this date in an Excel sheet: 01/08/2007. I import in into Mathematica. I want to prevent it from becoming an arithmetical expression, so I sorround it by Unevaluated, HoldAll, and other hold-like devices, but I do not obtain the desired result. The date becomes a division. For example, the output of HoldComplete[2+2] is HoldComplete[2+2] , but instead the output of HoldComplete[ 01/08/2007] is HoldComplete[1/(8x 2007)]. What I am overlooking? (Mathematica 9.0) Hi, Francisco, No need to use Hold or alike. I created the Excel file with the name "dateExample.xls". It only contains the date, the one you wish: 1/8/2007. Then I imported it into the notebook that was in the same directory as the Excel file as follows: imp=Import[NotebookDirectory[]<>"dateExample.xls"] This the outcome: {{{{2007,1,8,0,0,0.}}}} Then this: DateString[ imp[[1, 1, 1]], {"", "", "Month", "/", "Day", "/", "YearShort"}] yields the desired output: "01/08/07" It appears as a string and, therefore, is not considered by Mathematica as an arithmetic operation. Have fun, Alexei Alexei BOULBITCH, Dr., habil. IEE S.A. ZAE Weiergewan, 11, rue Edmond Reuter, L-5326 Contern, LUXEMBOURG Office phone : +352-2454-2566 Office fax: +352-2454-3566 mobile phone: +49 151 52 40 66 44 e-mail: alexei.boulbitch at iee.lu