Skip to contents

Checks to see if a date is past the user-specified cutoff point for delineating school years, then maps to the appropriate year.

Usage

date_to_sy(date_var, last_day_of_sy = NULL)

Arguments

date_var

the date to convert. Can be a Date object or a string in the form 'YYYY-MM-DD' or 'MM/DD/YYYY'

last_day_of_sy

the cutoff date, after which a date is considered part of the following school year. The year of this argument does not matter. Defaults (noisily) to July 1st.

Value

Returns a character vector in the format of "2013 - 2014"

A character vector the same length as date_var

Examples

date_to_sy(as.Date("2014-05-05"), as.Date("2000-07-01"))
#> [1] "2013 - 2014"
date_to_sy(as.Date("2014-07-05"), as.Date("2000-07-01"))
#> [1] "2014 - 2015"