Displaying 1 result from an estimated 1 matches for "sdate2".
Did you mean:
date2
2008 Apr 23
1
Time arithmetic
...lt;- function(s,d){
## Days in d months from s
sdate <- MSTD(s)
## Get day, month and the year
sd <- as.double(days(sdate))
sm <- as.double(months(sdate))
sy <- as.double.difftime(years(sdate))
sm <- sm+d
while(sm > 12){
sm <- sm-12
sy <- sy+1
}
sdate2 <- MSTD(paste(sd,sm,sy,sep="/"))
return(as.double(difftime(sdate2, sdate, units="days")))
}
MSTD <- function(a){
if(class(a)[1] == "dates") return (a)
return(dates(a, format="d/m/y"))
}
[[alternative HTML version deleted]]