Re: list of dates
- To: mathgroup at smc.vnet.net
- Subject: [mg88391] Re: list of dates
- From: "Roger Nye" <roger.nye at actuary.ch>
- Date: Sat, 3 May 2008 06:20:06 -0400 (EDT)
- References: <fvegu1$5e9$1@smc.vnet.net>
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? 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 > >
- Follow-Ups:
- Re: Re: list of dates
- From: Carl Woll <carlw@wolfram.com>
- Re: Re: list of dates