Re: list of dates
- To: mathgroup at smc.vnet.net
- Subject: [mg88353] Re: list of dates
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Fri, 2 May 2008 06:03:30 -0400 (EDT)
- Organization: The Open University, Milton Keynes, UK
- References: <fvegu1$5e9$1@smc.vnet.net>
Roger Nye wrote:
> 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?
To help you started, the following function assume an input date as a
string and that a year as 360 days (i.e. 12 months of 30 days).
myDate[d_String] := Module[{yy, mm, dd},
{yy, mm, dd} = DateList[d][[1 ;; 3]];
yy = yy - 1900;
td = 30 (mm - 1) + dd;
yy + Rescale[td, {1, 360}] // N
]
myDate["1963-01-01"]
myDate["1985-07-01"]
Out[79]= 63.
Out[80]= 85.5014
Regards,
-- Jean-Marc
- Follow-Ups:
- Re: Re: list of dates
- From: Stern <nycstern@gmail.com>
- Re: Re: list of dates