MathGroup Archive 2008

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

Search the Archive

Re: Re: list of dates

  • To: mathgroup at smc.vnet.net
  • Subject: [mg88438] Re: [mg88391] Re: list of dates
  • From: Carl Woll <carlw at wolfram.com>
  • Date: Mon, 5 May 2008 06:14:49 -0400 (EDT)
  • References: <fvegu1$5e9$1@smc.vnet.net> <200805031020.GAA04214@smc.vnet.net>

Roger Nye wrote:

>Thanks for your suggestions.
>
>A key aspect of the problem is that the dates are a list, so I want to be 
>able to operate on them as a list.
>The approximation of leap years does not concern me, although the year has 
>to be correct (i.e. 1st Jan of year xx must be xx.0, not xx-1.997).
>
>Adapting your suggestions and after much struggle (I am new to Mathematica), 
>I came up with this
>("date" is the list of dates input, "t" is the list of values output):
>
>n = Length[date];
>year = Transpose[Map[DateList, date]][[1]];
>days =  Table[DateDifference[{year[[i]]}, date[[i]]], {i, 1, n}];
>t = year - 1900 + days / 365.24;
>
>which does what I wanted (thanks).
>It is however very slow.  It takes a couple of minutes for 15,000 dates.
>All the other software I have used for a similar calculation (Excel, Stata) 
>does it in a split second.
>
>Is there a much more efficient method?
>  
>
Yes, DateDifference is slow. Just use one of the methods based on 
AbsoluteTime.

Carl Woll
Wolfram Research

>Many thanks
>Roger
>
>
>"Roger Nye" <roger.nye at actuary.ch> wrote in message 
>news:fvegu1$5e9$1 at smc.vnet.net...
>  
>
>>Hi,
>>I have a list of dates in the format YYYY-MM-DD and I want to convert them
>>to a decimal value, so 1963-01-01 goes to 63.0 and 1985-07-01 goes roughly
>>to 85.5.
>>
>>Any suggestions on the best way to do this?
>>
>>Many thanks
>>Roger
>>
>>
>>    
>>
>
>  
>



  • Prev by Date: Re: Identical elements
  • Next by Date: Re: MenuView inside Manipulate
  • Previous by thread: Re: list of dates
  • Next by thread: Re: list of dates