/ Published in: R
This doesn't take into account holidays.
Expand |
Embed | Plain Text
incrementBusinessDays <- function(x,n) { x <- as.Date(x) bWeeks <- floor(n/5) bDays <- n %% 5 x <- (x + bWeeks*7) wd <- as.POSIXlt(x)$wday + bDays # Need to wrap around the weekend if(wd < 1) { x <- x + bDays - 2 } else if(wd > 5) { x <- x + bDays +2 } else { x <- x + bDays } x }
You need to login to post a comment.
