vignettes/busdates-introduction-vignette.Rmd
busdates-introduction-vignette.Rmd
Working with business dates can be cumbersome and error prone. busdater
aims to make it easier, by providing functionality, to get financial year, calendar year and month calculations. It returns start and end of the business periods.
Jurisdictions and organisations observe different start and end of financial year. parameter is 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. The default is taken from options and is “07-01” if not present.
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.
The package has 4 functions (2 deprecated):
get_fy
to return the financial (fiscal) year as integersget_boundary
to return start and end of a month and start and end of financial yearsFY
deprecated and same as get_fy
period_boundaries
deprecated and same as get_boundary
Enjoy!
get_fy
functionGiven the current date:
Return the current financial year as integer
Return financial year for given dates
dt <- as.Date(c("01-01-2018", "15-12-2017"), "%d-%m-%Y")
get_fy(date = dt[1])
#> [1] 2018
get_fy(date = dt)
#> [1] 2018 2018
Return the next financial year as integer
get_fy(offset_period = 1) # current financial year + 1
#> [1] 2020
get_fy(date = dt[1], offset_period = 1)
#> [1] 2019
get_fy(date = dt, offset_period = 1)
#> [1] 2019 2019
Return the previous financial year as integer
get_boundary
functionGiven the current date:
What is the 1st day of the current financial year
get_boundary()
#> [1] "2018-07-01"
get_boundary(opt_fy_start = "07-01")
#> [1] "2018-07-01"
get_boundary(opt_fy_start = "01-03")
#> [1] "2019-01-03"
The last day of the current financial year
The last day of the last calendar year
The last day of month 14 months from now
get_boundary(offset_period = 14, offset_type = "month",
bus_period = "M", boundary = "last day")
#> [1] "2020-03-31"
The first day of financial years for dates 3 months before the given dates