zoo has the "yearmon" class which will convert a date to a year +
0/12 to 11/12 to represent the month, disregarding the day, so:
library(zoo)
12 * as.numeric((as.yearmon("2006-03-07") - as.yearmon("2006-02-06"))) # 1
On 3/10/06, Smith, Phil <[EMAIL PROTECTED]> wrote:
> Hi R-people:
>
> I need a function to compute the number of months between 2 dates, in the
> same way a mother would do it.
>
> For example, if a kid is born on February 6, the number of months between
> that date and March 7 is exactly 1 month, although it is only 29 days.
>
> Thank you!
> Phil Smith
> CDC
>
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [email protected] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html