Skip to content

Instantly share code, notes, and snippets.

@mattparker-wf
Created February 20, 2015 00:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattparker-wf/5a194786b53831586f66 to your computer and use it in GitHub Desktop.
Save mattparker-wf/5a194786b53831586f66 to your computer and use it in GitHub Desktop.
Get the Monday or Sunday preceding a given date
# Source: the masterful Marc Schwartz, in this R-help thread:
# http://r.789695.n4.nabble.com/previous-monday-date-td3786395.html
# Getting the Monday preceding any date
# See ?cut.Date for additional info
as.Date(cut(Sys.Date(), breaks = "weeks"))
# Alternatively, the preceding Sunday:
as.Date(cut(Sys.Date(), breaks = "weeks", start.on.monday = FALSE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment