alternatively,

We can get the dates without using code, attached is the version with only excel's array formulas.

ABC1.xlsx