| diff_days | R Documentation |
Finds difftime(date1, date2) (i.e. date1 - date2) using units = "days", then converts
to a numeric.
diff_days(date1, date2, keep_times = FALSE)
date1, date2 |
A date or datetime. |
keep_times |
Logical. If |
By default, only the date part of any datetime inputs are used (the datetime is
first coerced to a date using lubridate::as_date()). If keep_times = TRUE and both
date1 and date2 are datetimes then the times will be used. See examples.
d1 <- lubridate::ymd_hms("2020-02-01 08:00:00")
d2 <- lubridate::ymd_hms("2020-01-01 00:00:00")
d3 <- lubridate::ymd("2020-01-01")
diff_days(d1, d2, keep_times = FALSE)
diff_days(d1, d2, keep_times = TRUE)
diff_days(d1, d3, keep_times = TRUE) # time in d1 not used since d3 is a date
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.