dates: Date Utility Functions

datesR Documentation

Date Utility Functions

Description

A set of helper functions for dealing with dates in a typical actuarial analysis context.

Derive the number of months elapsed between two dates.

Usage

end_of_month(date)

start_of_month(date)

extract_date(string)

elapsed_months(end_date, start_date)

Arguments

date

character or date representation of a date.

string

string to extract a date from

end_date

end date

start_date

start date

Value

  • end_of_month returns last day of the month given.

  • start_of_month returns the first day of the month given.

  • extract_date returns a date object extracted from the provided string.

numeric

See Also

as.Date(), lubridate::ceiling_date(), lubridate::floor_date(), flipTime::AsDate()

Examples

# character input
start_of_month("2020-08-13")
end_of_month("2017-10-20")

# can handle human-readable dates also
start_of_month("July 7, 1999")
end_of_month("February 5, 2019")

# date input
start_of_month(as.Date("2020-08-13"))
end_of_month(as.Date("2020-10-20"))

jimbrig/lossrx documentation built on Dec. 20, 2024, 3:46 a.m.