如何从日期时间减去几天? [英] How to subtract a number of days from a date-time?

查看:153
本文介绍了如何从日期时间减去几天?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当使用R时,如何从日期时间减去多少天,时钟时间
以以下方式写:2013-06-13 08:24:00。



例如。从2013-06-13 08:24:00减去一天,以获得2013-06-12 08:24:00。

解决方案

pre> library(lubridate)
x< - as.POSIXct(2013-06-13 08:24:00)

x - ddays 1) - dminutes(24)
#[1]2013-06-12 08:00:00 EEST


When using R how can I subtract a number of days from a date-time with clock time written in the following way: 2013-06-13 08:24:00.

E.g. subtract one day from 2013-06-13 08:24:00 to obtain 2013-06-12 08:24:00.

解决方案

library(lubridate)
x <- as.POSIXct("2013-06-13 08:24:00")

x - ddays(1) - dminutes(24)
#[1] "2013-06-12 08:00:00 EEST"

这篇关于如何从日期时间减去几天?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆