Change day of the month in a Date to first day (01)

前端 未结 5 866
别那么骄傲
别那么骄傲 2020-11-30 11:10

I want to set the day of month in a Date to start date of current month (01). Now I use the following:

currentDate <- Sys.Date()         


        
5条回答
  •  醉话见心
    2020-11-30 11:34

    Yes, there is a one-liner for that using function cut:

    cut(Sys.Date(), "month")
    [1] 2012-11-01
    Levels: 2012-11-01
    

提交回复
热议问题