title: How do I write an Excel formula to compare year-to-date to prior years & also account for leap years?
body: <p>I’m trying to compare a measure as of today through the same day and month for the prior 4 years (e.g. through June 6 of 2016, 2015, 2014, etc.).
  For each year, I decided to count the number of days since the beginning of the year, and sum my values through that number of days for each year.</p>
  
  <p>To identify whether a date should be included in the year to date comparison, I used the formula where my date is in cell A1:</p>
  
  <pre><code>=IF((A1-DATE(YEAR(A1),1,1)+1)&lt;=(TODAY()-DATE(YEAR(TODAY()),1,1)+1),1,0)
  </code></pre>
  
  <p>I’m looking for a way around the issue of the extra day added to leap years.  In other words, after February 28th, the day count will always be off by one in a leap year, and trying to use Februrary 29th in a non-leap year will return an error.</p>
  
  <p>I’d like to adjust this formula, but I’m open to using a different function &amp; formula if it gets me the right results.  </p>