How do I write an Excel formula to compare year-to-date to prior years & also account for leap years? -
i’m trying compare measure of today through same day , month prior 4 years (e.g. through june 6 of 2016, 2015, 2014, etc.). each year, decided count number of days since beginning of year, , sum values through number of days each year.
to identify whether date should included in year date comparison, used formula date in cell a1:
=if((a1-date(year(a1),1,1)+1)<=(today()-date(year(today()),1,1)+1),1,0)
i’m looking way around issue of day added leap years. in other words, after february 28th, day count off 1 in leap year, , trying use februrary 29th in non-leap year return error.
i’d adjust formula, i’m open using different function & formula if gets me right results.
you can check information february, 29th. if error occurs, know no leap year. catch error =iferror(;)
.