Count the months between two dates in a data.table
问题 I have a data.table like the following: ID start_date end_date 1 2015.01.01 2016.02.01 2 2015.06.01 2016.03.01 3 2016.01.01 2017.01.01 I would like to get the following: ID start_date end_date Months_passed 1 2015.01.01 2016.02.01 13 2 2015.06.01 2016.03.01 9 3 2016.01.01 2017.01.01 12 I was trying the following code: DT[, Months_passed:= length(seq(from = start_date, to = end_date, by='month')) - 1] but I get the error, that "Error in seq.Date(from = start_date, to = end_date, by = "month")