[R] Time difference in months? (difftime, units)

Andy Bunn abunn at whrc.org
Wed Nov 17 16:26:06 CET 2004


Is there a way to calculate the number of months between dates?

StartDate <- strptime("01 March 1950", "%d %B %Y")
EventDates <- strptime(c("01 April 1955", "01 July 1980"), "%d %B %Y")
difftime(EventDates, StartDate)

So, there are 61 months between 01 March 1950 and 01 April 1955. There are
364 months between 01 March 1950 and 01 July 1980. What I want is for there
to be a "months" argument to units in difftime. Anybody have a bright idea?
Is there a better way to approach this than difftime?

Thanks in advance, Andy


> version
         _
platform i386-pc-mingw32
arch     i386
os       mingw32
system   i386, mingw32
status
major    2
minor    0.0
year     2004
month    10
day      04
language R




More information about the R-help mailing list