Skip to content
Back to formatted view

Raw Message

Message-ID: <AANLkTin08jNgTo7rYtqxE31sBPuqspj7XCpU7_6+Szoq@mail.gmail.com>
Date: 2010-08-29T12:27:31Z
From: jim holtman
Subject: calculations with dates
In-Reply-To: <AANLkTi=ZVE6MeU8VH4Rro4+HRsEZHw3w8sfMweWwEpdi@mail.gmail.com>

Try this:

> x
  startdate   enddate
1 27SEP2005 01JAN2006
> x$start <- as.Date(x$startdate, format="%d%b%Y")
> x$end <- as.Date(x$enddate, format="%d%b%Y")
> x
  startdate   enddate      start        end
1 27SEP2005 01JAN2006 2005-09-27 2006-01-01
> x$duration <- x$end - x$start
> x
  startdate   enddate      start        end duration
1 27SEP2005 01JAN2006 2005-09-27 2006-01-01  96 days
>


On Sun, Aug 29, 2010 at 8:20 AM, Andr? de Boer <rnieuws at gmail.com> wrote:
> Hi,
>
> I have a data.frame with factors in columns like
>
> startdate ? ? ?enddate
> 27SEP2005 01JAN2006
>
> How can I calculate the duration between those two dates and move this in a
> extra column in the data.frame.
>
> Thanks,
> Andr?
>
> ? ? ? ?[[alternative HTML version deleted]]
>
>
> ______________________________________________
> R-help at 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.
>
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?