[R] Month Difference
    Marc Girondot 
    marc_grt at yahoo.fr
       
    Fri Sep  7 14:02:33 CEST 2012
    
    
  
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: marc.girondot at u-psud.fr
Web: http://www.ese.u-psud.fr/epc/conservation/Marc.html
Skype: girondot
    
    
More information about the R-help
mailing list