Le 07/09/12 10:26, Rantony a écrit :
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. Can any one help me please !
Here is a solution from here: http://129.175.106.17/epc/conservation/Girondot/Publications/Blog_r/Entrees/2011/9/18_Nombre_de_mois_entre_deux_dates.html num.months <-function ( x , y ) + { + x<-as.Date( x ) + y<-as.Date( y ) + seeq<-length(seq(from=x , to=y , by="months"))-1 + seeq + } x <- c("1981-12-01") y <- c("1990-05-01") indicemonth <- num.months ( x , y ) Sincerely Marc Girondot -- __________________________________________________________ Marc Girondot, Pr Laboratoire Ecologie, Systématique et Evolution Equipe de Conservation des Populations et des Communautés CNRS, AgroParisTech et Université Paris-Sud 11 , UMR 8079 Bâtiment 362 91405 Orsay Cedex, France Tel: 33 1 (0)1.69.15.72.30 Fax: 33 1 (0)1.69.15.73.53 e-mail: [email protected] Web: http://www.ese.u-psud.fr/epc/conservation/Marc.html Skype: girondot ______________________________________________ [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 and provide commented, minimal, self-contained, reproducible code.

