R/periodFromDates.R

Defines functions periodFromDates

Documented in periodFromDates

#' Period between two dates with format
#' @param from <date>
#' @param to <date>
#' @return chr variable with format

periodFromDates <- function(from, to, format = '%2d years and %2d months'){
  
  per <- lubridate::as.period(lubridate::interval(from, to), unit = "year")
  
  sprintf(format, per@year, per@month)
}
diegogarcilazo/myutilities documentation built on Jan. 4, 2024, 2:11 p.m.