how to extract duration from datetime columns

i have two columns with datetimes and i want to find the duration by subtracting end time from start time in a new column as days + hours + minutes format. how do i do that?

Here it is in years. Do what you need to get months and days out of it.

library(lubridate)
library(tidyverse)

tibble(start = ymd_hms("2009-03-08 01:59:00"),
             end = ymd_hms("2012-02-29 12:00:00")) %>% 
  mutate(years = interval(start, end) / years(1))
1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.