Navigate from a date the a given preceding ("prev") or following ("next") day of the week (default next/prev Monday).

next_day_of_week(date = today(), day = 1L, shift = 1L)

prev_day_of_week(date = today(), day = 1L, shift = -1L)

Arguments

date

Date vector

day

integer 1 for Monday to 7 for Sunday or character using days_of_week

shift

integer number of days to shift date by (the default 0L includes the date itself)

Value

Datevector

See also

Examples

# Next Friday
next_day_of_week(today(), 5L)
#> [1] "2022-06-03"

# Previous Friday
prev_day_of_week(today(), 5L)
#> [1] "2022-05-20"

# Saturday preceding April 11, 2022
prev_day_of_week("2022-04-11", 6L)
#> [1] "2022-04-09"