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
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("20061111", format="%Y%m%d") > end <- strptime("20081111", format="%Y%m%d") > end-startTime difference of 731 days HTH Sebastian -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 262 bytes Desc: OpenPGP digital signature URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120309/b908a170/attachment.bin>
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