Re: [R] question about difference in date objects

2009-11-02 Thread Prof Brian Ripley
On Mon, 2 Nov 2009, Phil Smith wrote: Hi R Community: I want to take the difference in two dates: dt2 - dt1. But, I want the answer in months between those 2 dates. Can you advise me? How long is a month? difftime() can give you an answer in days, which might suffice if you define a mont

Re: [R] question about difference in date objects

2009-11-02 Thread Gabor Grothendieck
Since months have different lengths the difference in months is not well defined but lets define it as the difference between the first of the month of two dates. In that case we can use as.yearmon of the zoo package. It converts to year/months, dropping days, using an internal representation of y

Re: [R] question about difference in date objects

2009-11-02 Thread Karl Ove Hufthammer
On Mon, 02 Nov 2009 06:29:54 -0500 Phil Smith wrote: > I want to take the difference in two dates: > > dt2 - dt1. > > But, I want the answer in months between those 2 dates. What do you mean by 'months'? The number of days in a month vary, so the number of months between two dates is not defi

[R] question about difference in date objects

2009-11-02 Thread Phil Smith
Hi R Community: I want to take the difference in two dates: dt2 - dt1. But, I want the answer in months between those 2 dates. Can you advise me? Please respond to: p...@cdc.gov Thank you! Phil Smith Centers for Disease Control and Prevention __ R