You can also do same using DATE
function, this gives you ability to generate months or years.
Pretending start date is written in A2
and end date is written in B2
.
This formula will generate a list of dates between (inluding start, excluding end).
=ARRAYFORMULA(DATE(YEAR(A2), MONTH(A2), DAY(A2) + SEQUENCE(DATEDIF(A2,B2,"D"), 1, 0, 1)))
Few explanations:
DATE
function has ability to move over month if days is over last day of that month of that year. Same goes for months.
DATEDIF(A2,B2,"D")
gives you amount of days between the dates. You can + 1
if you want to include end date.
SEQUENCE(DATEDIF(A2,B2,"D"), 1, 0, 1)
generates number from 0 to amount of days generated above.