powered by
Get First / Last Day of a Month
Get First or Last Day of Month From Year and Month
first_of_month(x)# S3 method for default first_of_month(x)last_of_month(x)# S3 method for default last_of_month(x)first_of_ym(x, m = NULL)last_of_ym(x, m = NULL)
# S3 method for default first_of_month(x)
last_of_month(x)
# S3 method for default last_of_month(x)
first_of_ym(x, m = NULL)
last_of_ym(x, m = NULL)
a Date
Anything that can be coerced to a date with base::as.Date()
base::as.Date()
Two integer (vectors). m is optional and the interpretation of x will depend on whether m is supplied or not:
m
x
if only x is supplied, x will be passed to as_date_ym() (e.g. x = 201604 means April 2016)
as_date_ym()
x = 201604
if x and m are supplied, x is interpreted as year and m as month.
first_of_month()
first_of_month("2016-06-04") last_of_month("2016-06-04") first_of_ym(2016, 1) first_of_ym(201601)
Run the code above in your browser using DataLab