Data Cornering
Here is probably the easiest way how to get the last or first date of the month that might be helpful in further calculations in R. You will need a lubridate package.