Find Last Day of Month for Particular Date in R (Example Code)
This article explains how to identify the last day of the month for a specific date in R.
Creation of Example Data
x <- as.Date("2025-07-03") # Example date x # [1] "2025-07-03" |
x <- as.Date("2025-07-03") # Example date x # [1] "2025-07-03"
Example: Find End of Month for Certain Date Using ceiling_date() Function of lubridate Package
install.packages("lubridate") # Install & load lubridate package library("lubridate") |
install.packages("lubridate") # Install & load lubridate package library("lubridate")
ceiling_date(x, "month") - days(1) # Get end of month # [1] "2025-07-31" |
ceiling_date(x, "month") - days(1) # Get end of month # [1] "2025-07-31"
Related Articles & Further Resources
Have a look at the following tutorials. They focus on topics such as dates and data objects.