I have two columns of data (both dates), and I need to find the number of days in between (basically the difference between the columns).
One of the columns is formatted like this (imported from SPSS) - I only included two rows as example: 12-Mar-2020 15:51:32 06-Apr-2019 17:08:03
What I need this to look like:
I tried using lubridate package, but it was not successful because of how this column is formatted (in case it's helpful, the class of this column is currently "character"). Please note: My data set is quite big, so I appreciate a solution that works on the entire column at once.
I would appreciate your help on this.
library(lubridate)
as_date(dmy_hms(c("12-Mar-2020 15:51:32", "06-Apr-2019 17:08:03")))
Result
[1] "2020-03-12" "2019-04-06"