Convert a date like 12/15/2024 to academic semester (2024 Fall). Note that to make it sort correctly, "Spring" is preceded by two spaces so that "2025 Spring" is alphabetically before "2025 Fall".

date_to_academic_semester(dates)

Arguments

date

A date or vector of dates

Value

a character string or vector with the academic year (i.e. "2024 Fall")

Examples

dates <- as.Date(c("12/20/2024", "06/01/2021", "09/01/2021"), format="%m/%d/%Y")
print(cbind(format(dates, "%m/%d/%Y"), date_to_academic_semester(dates)))
#>      [,1]         [,2]          
#> [1,] "12/20/2024" "2024 Fall"   
#> [2,] "06/01/2021" "2021  Spring"
#> [3,] "09/01/2021" "2021 Fall"