Find the Date : last monday

Hi,

Is there a way to "block" a date according to the Sys.Date() ?

I mean my goal is to find the date of the last monday.

Like Sys.Date()-1 if it's tuesday.. Sys.Date()-4 if friday...

But with an automatic way (i would like to use the code in a shiny app).

Using lubridate:

library(lubridate)
floor_date(today(), "week", 1) # if Monday the current day
floor_date(today() - 1, "week", 1) # if Monday the previous Monday
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.