我正在尝试构建文件夹以存储数据拉动.我想用拉动中的数据日标记文件夹.
防爆.我在5天前从mysql中提取数据我想将该文件夹命名为5天前的日期.
MySQL可以轻松处理日期算术.我不确定R是怎么做到的.我应该在POSIXct中减去适当的秒数然后转换为POSIXlt来命名文件夹MM_DD_YYYY吗?
或者,还有更好的方法?
我有一个像"2016-01-01"(YYYY-MM-DD)的日期,我正在as.numeric(as.POSIXct(...))使用它作为整数.
我的问题是,有没有办法在一年,一个月或一天中添加到这个日期?我的意思是,如果我在2016年增加一年,它将与2015年增加一年(bissextile stuff)相同.
与在1月1日添加32天相同,与在2月01日添加32天相同(因为可能更改的天数)
我设法把东西了年和月的作品,但我想实现天以及
how_long_is_simul <- function(lst){
# Format DATE_START
greg_date = intDate_to_gregorianDate(DATE_START)
reg = "^([0-9]{4})\\-([0-9]{2})\\-([0-9]{2})$" # black-magic
splited_date = str_match(greg_date, reg)
# Manage months limit
lst$years = lst$years + floor(lst$months/12)
lst$months = lst$months%%12
# Build new date
my_vector = c(lst$years, lst$months, 0)
end_date = paste(as.numeric(splited_date[2:4]) + my_vector, collapse = "-")
return(round((gregorianDate_to_intDate(end_date)-DATE_START)/86400))
}
# AND the vars used by the function
DATE_START <- 1451606400 # 2016-01-01 GMT
lst = list( # no days, …Run Code Online (Sandbox Code Playgroud)