Hi,
Try this:
dat3<-read.table(text="
Begin_date????????????????????????? End_date
01JAN2000:00:00:00:000????? 02FEB2002:00:00:00:000
24MAR2012:00:00:00:000????? 18MAY2012:00:00:00:000
01OCT2003:00:00:00:000????? 02FEB2004:00:00:00:000
01JAN2000:00:00:00:000????? 02FEB2000:00:00:00:000
01JAN2000:00:00:00:000????? 02FEB2000:00:00:00:000
",sep="",header=TRUE)
dat3$Begin_date<-strptime(dat3[,1],format="%d%b%Y:%H:%M:%S")
dat3$End_date<-strptime(dat3[,2],format="%d%b%Y:%H:%M:%S")
?difftime(dat3[,1],dat3[,2])
Time differences in days
[1] -763.0000? -55.0000 -124.0417? -32.0000? -32.0000
attr(,"tzone")
[1] ""
A.K.
----- Original Message -----
From: C W <tmrsg11 at gmail.com>
To: r-help <r-help at r-project.org>
Cc:
Sent: Tuesday, July 10, 2012 1:22 PM
Subject: [R] calculating the difference between days?
Hi List,
I have one column of beginning dates and one column of ending dates, I want
to find their difference.? And I want to ignore the trailing zeros,
basically everything after the first colon mark.
Begin_date? ? ? ? ? ? ? ? ? ? ? ? ? End_date
01JAN2000:00:00:00:000? ? ? 02FEB2002:00:00:00:000
24MAR2012:00:00:00:000? ? ? 18MAY2012:00:00:00:000
01OCT2003:00:00:00:000? ? ? 02FEB2004:00:00:00:000
01JAN2000:00:00:00:000? ? ? 02FEB2000:00:00:00:000
01JAN2000:00:00:00:000? ? ? 02FEB2000:00:00:00:000
Thanks,
Mike
??? [[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.