Calendar: formulas & methods

Keep the method clear, then put it into practice.

These methods use the Gregorian calendar, extended consistently to all positive year numbers. Weekday shifts depend on elapsed days modulo 7.

Y
Positive year number.
L(Y)
leap years among years 1 through Y.
d
Elapsed days.
w
weekday index: Monday=0,…,Sunday=6.

Leap-year rule

Leap if divisible by 400, or divisible by 4 but not 100

A leap year has 366 days; otherwise 365.

Leap-year count

L(Y)=⌊Y/4⌋−⌊Y/100⌋+⌊Y/400⌋

For Y≥0; count in years A…B is L(B)−L(A−1).

Weekday shift

New weekday=(old weekday+d) mod 7

Use elapsed days, not an inclusive count of both endpoint dates.

Odd days

365 mod 7=1; 366 mod 7=2

An “odd day” is a leftover day, not an odd-numbered date.

January 1 weekday

w=[365(Y−1)+L(Y−1)] mod 7

Monday=0, using Gregorian January 1, year 1 as Monday.

Any date in the year

w(date)=[w(January 1)+D−1] mod 7

Compute ordinal D using the correct leap-year month lengths.

Explanations and worked examples

Open a method when you need more detail.

Full notation guide
Y
Positive year number.
L(Y)
leap years among years 1 through Y.
d
Elapsed days.
w
weekday index: Monday=0,…,Sunday=6.
⌊x⌋
Floor: the greatest integer not exceeding x.
D
Ordinal day within a year, with January 1 as D=1.
1. Apply the century exceptions

Ordinary multiples of 4 are leap years, but century years must be divisible by 400. This prevents treating every fourth year as a leap year across century boundaries.

Leap ⇔ (Y divisible by 400) or (Y divisible by 4 and not 100)
Worked example

Which of 1900, 2000 and 2024 are leap years?

  1. 1900 is divisible by 100 but not 400: not leap.
  2. 2000 is divisible by 400: leap.
  3. 2024 is divisible by 4 and not 100: leap.

2000 and 2024.

Remember

  • Historical calendars varied by country. These aptitude rules use Gregorian dates and not Julian-calendar adoption histories.
2. Count leap years in a range

Count multiples of 4, subtract multiples of 100, and add back multiples of 400. To count an inclusive range A through B, subtract cumulative counts through A−1 from those through B.

L(Y)=⌊Y/4⌋−⌊Y/100⌋+⌊Y/400⌋
Worked example

How many leap years occur from 2000 through 2099 inclusive?

  1. L(2099)=524−20+5=509.
  2. L(1999)=499−19+4=484.
  3. Count=509−484=25.

25 leap years.

Remember

  • Do not exclude the starting year when the question says inclusive.
3. Shift weekdays by elapsed days

Each complete group of 7 days leaves the weekday unchanged. Reduce the elapsed interval modulo 7. The starting date is time zero, so the next date is one day later.

Weekday shift=d mod 7
Worked example

If today is Wednesday, what weekday is it 100 days later?

  1. 100=14×7+2.
  2. Move two days forward from Wednesday.

Friday.

Remember

  • “100 days later” differs from the 100th day in a count that labels today as day 1.
4. Compute an ordinal day using month lengths

Month lengths are 31,28 or 29,31,30,31,30,31,31,30,31,30,31 from January through December. Add days in preceding months, then the day of the month.

D=sum of earlier month lengths+day of month
Worked example

How many days elapse from February 28, 2024 to March 1, 2024?

  1. 2024 is leap, so February has 29 days.
  2. March 1 has ordinal 31+29+1=61.
  3. February 28 has ordinal 31+28=59.
  4. Elapsed days=61−59=2.

2 days.

Remember

  • There are three named dates in an inclusive listing, but only two elapsed day intervals.
5. Calculate a weekday from a fixed anchor

January 1 of Gregorian year 1 is Monday in the proleptic Gregorian system. Count all days in prior years, then add D−1 for the current year. Reduce modulo 7.

w=[365(Y−1)+L(Y−1)+D−1] mod 7
Worked example

Find the weekday of January 1, 2000.

  1. Prior years=1999; leap years among them=484.
  2. Days before the date=365×1999+484.
  3. Remainder modulo 7=5; with Monday=0, index 5 is Saturday.

Saturday.

Remember

  • A different anchor or weekday numbering works only if it is used consistently throughout.
6. Match whole-year calendars by two conditions

Two years have the same full calendar exactly when their January 1 weekdays agree and they are both ordinary years or both leap years. Test these conditions rather than assuming a universal repetition interval.

Same calendar ⇔ same January 1 weekday and same leap status
Worked example

Do 2021 and 2027 share the same Gregorian calendar?

  1. Both are ordinary years.
  2. From January 1, 2021 to January 1, 2027 there are six ordinary-year shifts plus the extra leap day in 2024: 7 days modulo a week.
  3. January 1 therefore has the same weekday in both.

Yes.

Remember

  • A 28-year shortcut can fail across a non-leap century. The complete Gregorian pattern repeats after 400 years.
Practise calendar questions