Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #16559
| From | Alexei Boulbitch <Alexei.Boulbitch@iee.lu> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: hold question |
| Date | 2014-02-12 10:05 +0000 |
| Message-ID | <ldfh17$bvb$1@smc.vnet.net> (permalink) |
| Organization | Time-Warner Telecom |
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@iee.lu
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar
Re: hold question Alexei Boulbitch <Alexei.Boulbitch@iee.lu> - 2014-02-12 10:05 +0000
csiph-web