Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2014

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

Search the Archive

Re: hold question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg132332] Re: hold question
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Tue, 11 Feb 2014 02:57:42 -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

On 2/10/14 at 3:01 AM, fgutiers2002 at yahoo.com (Francisco Gutierrez)
wrote:

>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)].

I use one of two methods to move dates from Excel to
Mathematica. First, is to simply use Import to import the entire
spread sheet or some portion of it into Mathematica. Import will
return {2007,1,8} for a cell with the Excel date 01/08/2007.

The second way would be to reformat the Excel cell containing
the date as General which will convert the cell to display an
integer 39090. Then I can copy and paste that integer into a
Mathematica expression to get a date as follows:

In[2]:= DateString[(39090 - 2) 86400]

Out[2]= Mon 8 Jan 2007 00:00:00

The 2 is to adjust for an offset between Excel and Mathematica
date formats. The second constant is the number of seconds in a
day, required since Excel tracks dates in terms of days while
Mathematica does so in terms of seconds.




  • Prev by Date: Re: animation of the PDE
  • Next by Date: Re: RowBox disappearing Lines
  • Previous by thread: Re: hold question
  • Next by thread: Re: hold question