Getting previous month start date and end date from current date in R

后端 未结 6 1562
心在旅途
心在旅途 2020-12-29 03:55

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

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-29 04:35

    Previous Month Start Date:

    format(Sys.Date() - 30, '%Y-%m-01')
    

    Previous Month End Date:

    as.Date(format(Sys.Date(), '%Y-%m-01')) - 1
    

提交回复
热议问题