Is there any easy way for getting start date and end date of previous month from the current date in R?
I have only the current date. From it, i want to get the prev
Using lubridate it's a piece of cake:
library(lubridate)
floor_date(Sys.Date() - months(1), "month")
There is a plenty of good libraries in R. Seems like everything you need is already created.
UPDATED version:
library(lubridate)
floor_date(as.Date("2011-03-29"), "month") - months(1)
This one is corrected to work well with the 29th of march.