Re: list of dates
- To: mathgroup at smc.vnet.net
- Subject: [mg88363] Re: [mg88334] list of dates
- From: Carl Woll <carlw at wolfram.com>
- Date: Sat, 3 May 2008 06:15:03 -0400 (EDT)
- References: <200805020742.DAA05390@smc.vnet.net> <481B0DB8.5020703@wolfram.com>
Carl Woll wrote:
> Roger Nye wrote:
>
>> 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
>>
>>
> Perhaps Developer`CalendarData may help:
>
> In[102]:= Developer`CalendarData[{1985, 7, 1}, "TimeInYear"]
>
> Out[102]= 0.49589
>
> An alternative is to use DateDifference:
>
> In[103]:= DateDifference[{1985, 1, 1}, {1985, 7, 1}, "Year"]
>
> Out[103]= {0.49589,Year}
>
> Carl Woll
> Wolfram Research
>
I forgot to mention that DateDifference and Developer`CalendarData both
accept any date input accepted by DateList as well:
In[105]:= Developer`CalendarData["1985-07-01", "TimeInYear"]
Out[105]= 0.49589
In[106]:= DateDifference["1985-1-1", "1985-7-1", "Year"]
Out[106]= {0.49589,Year}
In[107]:= DateDifference[{1963}, "1963-1-1", "Year"]
Out[107]= {0,Year}
Carl Woll
Wolfram Research
- References:
- list of dates
- From: "Roger Nye" <roger.nye@actuary.ch>
- list of dates