[英]How can I calculate the difference between these two dates using R?
I have a data set which containing 2 columns with dates with the following formats:我有一个数据集,其中包含 2 列,日期格式如下:
"2027-02-20 00:00:00 CET" and "2014-12-31 CET"
how can I calculate the difference between these two dates?如何计算这两个日期之间的差异? Or, how can I apply difftime
?或者,我如何应用difftime
?
Here is a useful discussion but I cannot apply it directly?! 这是一个有用的讨论,但我不能直接应用它?!
I gave by myself the link (above see: Here is blue) where one can find a very similar problem but not exact the same.我自己给了一个链接(见上图:这里是蓝色),人们可以在其中找到一个非常相似但不完全相同的问题。 Unfortunately some of people do not read the question carefully.不幸的是,有些人没有仔细阅读问题。 Just one gave a useful hint.只有一个给出了有用的提示。 One dose not need any string manipulation!一剂不需要任何字符串操作!
I solved my problem, the hint of Roland was really useful.我的问题解决了,罗兰的提示真的很有用。 I did not really need any string manipulation.我真的不需要任何字符串操作。 If I apply如果我申请
difftime(strptime("2027-02-20 00:00:00 CET", format = "%Y-%m-%d"),
strptime("2014-12-31 CET", format = "%Y-%m-%d"),units="weeks")
it works well.它运作良好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.