I have the following dataset:
start_date <- c("2020-07-01 04:00:00", "2021-01-01 12:01:01")
end_date <- c("2021-01-10 01:12:11", "2021_02-02 12:12:12")
dates <- data.frame(start_date, end_date)
I am trying to calculate the total time between the start and end date. I started by parsing the datetime using
dates <- dates %>%
mutate(start_date = parse_datetime(start_date, "%m/%d/%Y %H:%M:%s"))
dates <- dates %>%
mutate(end_date = parse_datetime(end_date, "%m/%d/%Y %H:%M:%s"))
I then subtracted the two using:
dates <- dates %>%
mutate(date_diff = start_date - end_date)
But I ended up with a value rounded to the nearest hour wherein I wanted a value rounded to the nearest second. How can I do that?