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"

Example: Find End of Month for Certain Date Using ceiling_date() Function of lubridate Package

install.packages("lubridate")         # Install & load lubridate package
library("lubridate")
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.

Leave a Reply

Your email address will not be published.

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed

Menu
Top