Calculating time to event variable

Is my calculation of the time to event variable correct?

id generic_name index_date ami_ae ami_pre_date ami_post_date t2amiae dm2_ae dm2_pre_date dm2_post_date t2dm2_ae
1 atorvastatin 10/27/2016 1 10/10/2015 12/1/2016 35 1 NULL NULL 0
2 simvastatin 7/12/2017 0 NULL NULL 0 1 NULL 9/23/2017 73
3 simvastatin 1/22/2015 0 0 0 0 1 0 1/1/2021 2171

The study duration is 2015-01-01 till 2019-12-31. The third observation is therefore right-censored. My question is did I calculate the days to the event from index date correctly including for the third row?