How to calculate time interval(time difference) between two Date columns(variables)— Hacking R
1 min readNov 24, 2019
INGREDIENTS:
Let’s create a data frame that contains two columns “Manufacturing Date”
INSTRUCTIONS:
Check the data type of columns. If columns are not “Date” type, then convert the type as “Date” using “as.Date” function.
Calculate time interval between “manufacturing_date” and “expiration_date”. Then, convert the time interval from days to months, and years.