[R] time between two dates
Dear All, It may be a trivial question but how to determine the number of days between two dates? What I want to do is to subtract two dates by a function which returns the number of days between these two dates. 11.11.2008-11.11.2006 ~= 730 days Look forward to your reply, Carol __ 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.
Re: [R] time between two dates
On 09/03/12 10:04, carol white wrote: Dear All, It may be a trivial question but how to determine the number of days between two dates? What I want to do is to subtract two dates by a function which returns the number of days between these two dates. 11.11.2008-11.11.2006 ~= 730 days start - strptime(2006, format=%Y%m%d) end - strptime(2008, format=%Y%m%d) end-start Time difference of 731 days HTH Sebastian signature.asc Description: OpenPGP digital signature __ 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.
Re: [R] time between two dates
On 09-03-2012, at 10:04, carol white wrote: Dear All, It may be a trivial question but how to determine the number of days between two dates? What I want to do is to subtract two dates by a function which returns the number of days between these two dates. 11.11.2008-11.11.2006 ~= 730 days x - as.Date(c(11-11-2008,11-11-2006),format=%d-%m-%Y) difftime(x[1],x[2],units=days) 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.