Days in a Year (Leap-Aware)

Excel Formulas › Date & Time

All versionsDATE

365 or 366? Rather than hardcode it, compute the days in a year by subtracting consecutive Jan-1 dates — automatically correct for leap years.


Quick formula: days in the year of A2:
=DATE(YEAR(A2)+1, 1, 1) - DATE(YEAR(A2), 1, 1)
Next January 1 minus this January 1 is the number of days in the year — 366 in leap years, 365 otherwise.

Functions used (tap for the full reference guide):

The example

2026 has 365 days; 2028 has 366.

AB
1YearDays
22026365
32028366

The formula

Difference of consecutive new-year dates:

=DATE(YEAR(A2)+1, 1, 1) - DATE(YEAR(A2), 1, 1) // 365 or 366, leap-aware

How it works

Let the calendar do the leap-year logic:

  1. DATE(year, 1, 1) is January 1; DATE(year+1, 1, 1) is next January 1.
  2. Their difference is the number of days in the year — no leap-year formula needed.
  3. A leap year returns 366 because February has 29 days; otherwise 365.
  4. To just test for a leap year: =DAY(DATE(year, 2, 29)) = 29 — TRUE if Feb 29 exists.

Why not hardcode 365? Day-count and interest calculations that assume 365 drift in leap years. Using the actual count keeps annualized rates and prorations exact. YEARFRAC with the right basis handles this for you in financial contexts.

Try it: interactive demo

Live demo

Enter a year.

Days: ·

Variations

Is it a leap year?

TRUE/FALSE:

=DAY(DATE(A2, 2, 29)) = 29

Days so far this year

Day of year:

=A2 - DATE(YEAR(A2), 1, 1) + 1

Days remaining

To year-end:

=DATE(YEAR(A2), 12, 31) - A2

Pitfalls & errors

Don’t assume 365. Leap years break hardcoded day counts in prorations and rates.

Result is a number. The subtraction returns a count, but if the cell is date-formatted it may show oddly — use General/Number.

Leap rules. Excel follows the standard Gregorian rule (and the 1900 leap-year quirk for legacy serials) — fine for modern dates.

Practice workbook

📊
Download the free Days in a Year (Leap-Aware) practice workbook
A days-in-year calculator with leap-test, day-of-year, and days-remaining variants, plus 4 challenges with answers. No sign-up required.

Frequently asked questions

How do I find the number of days in a year in Excel?
Subtract consecutive new-year dates: =DATE(YEAR(A2)+1,1,1) - DATE(YEAR(A2),1,1). It returns 366 in leap years and 365 otherwise.
How do I test for a leap year?
Check whether Feb 29 exists: =DAY(DATE(year, 2, 29)) = 29 returns TRUE for a leap year.
Why not just use 365?
Leap years make a hardcoded 365 drift in day-count and interest calculations. Computing the actual days keeps annualized figures exact.

Stop fighting formulas. Learn them in a day.

This recipe is one of hundreds of real-world formulas we teach. Our Excel Formulas & Functions class covers lookups, logic, text, and dynamic arrays hands-on — live in Dallas–Fort Worth, Houston, Austin, Oklahoma City, Denver, or online.

See the Formulas & Functions Class

Related formulas: Days in month · Exact age (y/m/d) · DAYS360 calculation

Function references: DATE