get_fy()
returns the current financial (fiscal) year.
It also returns financial year based on parameter dates, or financial year
based on a parameter dates and offset_period in years.
get_fy(date = Sys.Date(), offset_period = 0, opt_fy_start = getOption("busdaterFYstart", default = "07-01"))
date | A date vector for which financial year is required. Date must be POSIXct or POSIXlt or Date objects. |
---|---|
offset_period | A positive or negative number coercible to
integer to shift the year by,
e.g. in the case of |
opt_fy_start | A string in the format of "MM-DD" representing the start of financial year, e.g. "01-01" for 1st of January or "07-01" for 1st of July. This package caters for financial years that have a fixed start date. It does not cater for moving dates e.g. last Friday of September. |
An integer vector containing the current financial year if offset
offset_period
is 0, otherwise add the offset offset_period
in years.
Other business date functions: FY
,
get_boundary
,
period_boundaries
get_fy() ## return the current financial year as integer#> [1] 2019#> [1] 2018get_fy(date = dt)#> [1] 2018 2018get_fy(offset_period = 1) ## return the next financial year as integer#> [1] 2020get_fy(date = dt[1], offset_period = 1)#> [1] 2019get_fy(date = dt, offset_period = 1)#> [1] 2019 2019get_fy(offset_period=-1) ## return the previous financial year as integer#> [1] 2018get_fy(date = dt[1], offset_period = -1)#> [1] 2017get_fy(date = dt, offset_period = -1)#> [1] 2017 2017# NOT RUN { get_fy("a") ## will fail because dates are expected. # }