Returns the amount of business days between 2 dates taking into account the
provided Calendar
(or bizdays.options$get("default.calendar")
).
bizdays(from, to, cal)
the initial dates
the final dates
the calendar's name
integer
objects representing the amount of business days.
The arguments from
and to
accept Date
objects and any
object that returns a valid Date
object when passed through
as.Date
, which include all POSIX*
classes and character
objects with ISO formatted dates.
These arguments handle the recycle rule so vectors of dates can be provided and once those vectors differs in length the recycle rule is applied.
from
and to
are adjusted when nonworking dates are
provided. Since bizdays
function returns the amount of business days
between 2 dates, it must start and end in business days.
The default behavior, that is defined in Calendar
's instantiation with
adjust.from
and adjust.to
, reproduces the Excel's NETWORKDAYS.
A common and useful setting is adjust.to=adjust.next
which moves
expiring maturities to the next business day, once it is not.
bizdays("2013-01-02", "2013-01-31", "Brazil/ANBIMA")
#> [1] 21
# Once you have a default calendar set, cal does not need to be provided
bizdays.options$set(default.calendar = "Brazil/ANBIMA")
bizdays("2013-01-02", "2013-01-31")
#> [1] 21
dates <- bizseq("2013-01-01", "2013-01-10")
bizdays(dates, "2014-01-31")
#> [1] 274 273 272 271 270 269 268