Get a list of years between two dates

Hi!

Can anyone help with a function that takes two dates and returns an array of all the years completed between the two dates?

For example:

date_1: 01-01-2017

date_2: 31-08-2021

The output should be:

2017, 2018, 2019, 2020 (not including 2021 because it is not a completed year).

Thanks in advance!

2 replies