On 07-09-2012, at 10:26, Rantony wrote:

> Hi,
> 
> i need a small help.  
> 
> a<- as.Date("2012-01-01")
> b<- as.Date("2012-12-01")
> ------------------------------------
> My requirement what is, i need to get the month difference of these two
> dates.

One way is:

library(zoo)
(as.yearmon(b)-as.yearmon(a))*12

or

a.lt <- as.POSIXlt(a)
b.lt <- as.POSIXlt(b)
b.lt$mon-a.lt$mon

Searching in Google with  "R date difference months" gives quite a few 
interesting results.

Berend

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to