How to Calculate the Day of the Week
Determining what day of the week a given date falls on is a classic problem in calendar mathematics. While modern computers can answer this question instantly using built-in date libraries, mathematicians and enthusiasts have developed several elegant algorithms for calculating the day of the week by hand. Understanding these algorithms provides insight into how calendars work and why their structure can seem irregular.
The most well-known algorithm is Zeller's congruence, developed by Christian Zeller in 1887. The formula takes the day, month, year, and century as inputs and produces a number from 0 to 6, where each number corresponds to a day of the week. Zeller's formula uses modular arithmetic (the remainder after division) to account for the irregular month lengths and leap year rules in the Gregorian calendar.
Another popular method is the Doomsday algorithm, invented by mathematician John Conway in 1973. This method is designed to be performed mentally and relies on the fact that certain easy-to-remember dates always fall on the same day of the week in any given year. These "Doomsday" reference dates include 4/4, 6/6, 8/8, 10/10, 12/12, and the last day of February. Once you know what day of the week the Doomsday falls on for a particular year, you can count forward or backward from the nearest reference date to find the day for any date in that year.
For example, in 2026, the Doomsday (the day that all reference dates fall on) is Saturday. This means April 4, June 6, August 8, October 10, and December 12 are all Saturdays in 2026. To find what day March 7 falls on, you would note that March 7 is the day after February's last day (the Doomsday), so you count forward from the last day of February. Since February 28, 2026, is a Saturday (the Doomsday), March 7 is the following Saturday — exactly one week later. Therefore, March 7, 2026, is a Saturday.
In practice, most people simply use a calculator or calendar app rather than performing the arithmetic by hand. This calculator uses JavaScript's Date object, which internally counts the number of days since a reference date and uses modular arithmetic to determine the day of the week. The result is instantaneous and handles all edge cases, including leap years and dates far in the past or future.
The Gregorian Calendar
The Gregorian calendar is the calendar system used by virtually every country in the world for civil purposes. It was introduced by Pope Gregory XIII in 1582 as a reform of the Julian calendar, which had been in use since 46 BCE. The reform was necessary because the Julian calendar's leap year rule was slightly too generous, causing the calendar to drift by about 3 days every 400 years relative to the astronomical seasons.
The Gregorian calendar uses the following rules. An ordinary year has 365 days. A leap year has 366 days, with the extra day added to February. A year is a leap year if it is divisible by 4, unless it is divisible by 100, unless it is also divisible by 400. This rule produces an average year length of 365.2425 days, which is extremely close to the actual tropical year of approximately 365.2422 days. The remaining error amounts to about 1 day every 3,236 years.
The 12 months of the Gregorian calendar have irregular lengths: January (31), February (28 or 29), March (31), April (30), May (31), June (30), July (31), August (31), September (30), October (31), November (30), December (31). This irregularity is a source of confusion and the reason why day-of-week calculations are not trivial. If every month had the same number of days, the day of the week would follow a simple repeating pattern.
The Gregorian calendar was adopted at different times by different countries. Catholic countries in Europe adopted it in 1582. Protestant countries followed over the next two centuries. Britain and its colonies (including what would become the United States) adopted it in 1752, skipping 11 days in September. Russia did not adopt the Gregorian calendar until 1918, and Greece adopted it in 1923. When using this calculator for historical dates, keep in mind that dates before the local adoption of the Gregorian calendar may have been recorded in the Julian calendar and may not match modern calculations.
History of the 7-Day Week
The seven-day week is one of the oldest and most enduring units of time measurement in human history. Unlike the day, month, and year, which are based on observable astronomical cycles (Earth's rotation, the Moon's orbit, and Earth's orbit around the Sun), the seven-day week has no astronomical basis. It is a purely cultural convention.
The origin of the seven-day week is generally traced to ancient Mesopotamia (modern-day Iraq), where the Babylonians used a seven-day cycle as early as the 7th century BCE. The Babylonians were skilled astronomers and recognized seven celestial bodies visible to the naked eye: the Sun, Moon, Mars, Mercury, Jupiter, Venus, and Saturn. They associated each day of their week with one of these bodies, a practice that has persisted in modified form to this day.
The ancient Romans adopted the seven-day week and named the days after the same celestial bodies in Latin: dies Solis (Sun), dies Lunae (Moon), dies Martis (Mars), dies Mercurii (Mercury), dies Jovis (Jupiter), dies Veneris (Venus), and dies Saturni (Saturn). When Germanic tribes encountered the Roman calendar, they replaced the Roman god names with their own equivalents. Tuesday comes from Tiw (the Germanic god of war, equivalent to Mars). Wednesday comes from Woden (equivalent to Mercury). Thursday from Thor (equivalent to Jupiter). Friday from Frigga (equivalent to Venus). The English names Saturday, Sunday, and Monday retain their Latin-derived celestial references.
The seven-day week was also adopted independently in Judaism, where the seven-day creation narrative in Genesis established the Sabbath as the seventh day of rest. Christianity and Islam inherited the seven-day cycle, further cementing it as a global standard. By the time of the late Roman Empire, the seven-day week was established throughout Europe and the Middle East, and it has spread worldwide with European colonization and globalization.
Despite various attempts to reform the week — the French Revolutionary calendar used a 10-day "decade," and the Soviet Union experimented with 5-day and 6-day weeks in the 1930s — the seven-day week has proven remarkably resistant to change. It remains the universal standard for organizing work, rest, religious observance, and social life.
Day of Year and ISO Week Numbers
The day of year (also called the ordinal date or Julian day of year) is simply the sequential number of a given date within its year. January 1 is day 1, January 2 is day 2, and so on through December 31, which is day 365 (or 366 in a leap year). The day of year is useful in agriculture, meteorology, and astronomy, where events and measurements are often indexed by ordinal date rather than month and day.
To calculate the day of year for any date, add the number of days in all preceding months plus the day of the current month. For example, March 7 is 31 (January) + 28 (February, non-leap year) + 7 = day 66. In a leap year, March 7 would be day 67 because February has 29 days.
The ISO week number is defined by the ISO 8601 standard and is widely used in business, especially in Europe. ISO weeks start on Monday and end on Sunday. The first ISO week of the year is the week containing the first Thursday of January (equivalently, the week containing January 4). This definition means that ISO week 1 always includes at least 4 days of the new year. Some years have 52 ISO weeks, while others have 53.
The ISO week system can produce counterintuitive results at the boundaries of the year. December 29, 30, and 31 may fall in ISO week 1 of the following year if they are Monday, Tuesday, or Wednesday. Similarly, January 1, 2, and 3 may fall in ISO week 52 or 53 of the previous year if they are Friday, Saturday, or Sunday. For example, January 1, 2027, is a Friday, so it belongs to ISO week 53 of 2026.
Famous Dates and Their Days of the Week
Knowing the day of the week for famous historical events can be a fun exercise and a way to put calendar math into context. Here are some notable dates and the days they fell on:
- July 4, 1776 (US Declaration of Independence) – Thursday
- July 20, 1969 (Apollo 11 Moon landing) – Sunday
- November 9, 1989 (Fall of the Berlin Wall) – Thursday
- September 11, 2001 (9/11 attacks) – Tuesday
- January 20, 2009 (Barack Obama's first inauguration) – Tuesday
- February 29, 2000 (Leap day in a century year) – Tuesday
- December 25, 2025 (Christmas Day 2025) – Thursday
You can verify all of these using this calculator by entering the date and checking the result. It is a great way to test your mental day-of-week calculation skills if you practice the Doomsday algorithm or Zeller's congruence.
Calendar Patterns and Cycles
The Gregorian calendar follows repeating patterns that calendar enthusiasts find fascinating. Here are some of the most notable patterns:
The 400-year cycle. The Gregorian calendar repeats exactly every 400 years. The pattern of days, months, and leap years in the years 2000 through 2399 is identical to the pattern in 2400 through 2799. This is because 400 Gregorian years contain exactly 146,097 days, which is exactly 20,871 weeks. Since the number of days is an exact multiple of 7, the days of the week align perfectly after 400 years.
The 28-year cycle (with exceptions). Within a century, the calendar repeats every 28 years because 28 years contain exactly 1,461 weeks (accounting for 7 leap years). However, this pattern breaks at century boundaries that are not divisible by 400 (like 1900 and 2100, which are not leap years). The next break will occur in 2100.
Identical calendars. Two years share the same calendar (same day of week for every date) if they start on the same day and are both leap years or both non-leap years. For example, 2026 and 2037 both start on Thursday and are non-leap years, so they have identical calendars. You can reuse a 2026 wall calendar in 2037.
Friday the 13th. Every year has at least one Friday the 13th and at most three. The 13th falls on a Friday whenever the month begins on a Sunday. February 2026 begins on a Sunday, so February 13, 2026, is a Friday. The distribution of Friday the 13ths follows the same 400-year cycle as the rest of the calendar.
Frequently Asked Questions
How do you calculate the day of the week for any date?
Mathematicians use algorithms like Zeller's congruence or the Doomsday algorithm, which apply modular arithmetic to the year, month, and day components of a date. Computers use built-in date libraries that count the number of days from a known reference point and compute the remainder when divided by 7. This calculator uses JavaScript's Date object to determine the day of the week instantly for any date.
What is an ISO week number?
An ISO week number is defined by the ISO 8601 international standard. Weeks start on Monday and end on Sunday. The first week of the year (week 1) is the week containing the first Thursday of January. ISO week numbers range from 1 to 52 or 53. Some years have 53 weeks if December 31 falls on a Thursday (or Wednesday in a leap year). The ISO week system is widely used in European business and project planning.
Why does the 7-day week exist?
The 7-day week originated in ancient Mesopotamia around 2000 BCE, likely inspired by the seven celestial bodies visible to the naked eye: the Sun, Moon, Mars, Mercury, Jupiter, Venus, and Saturn. Unlike the day, month, and year, the week has no astronomical basis and is purely a cultural convention. It was adopted by Romans, spread through Christianity, Judaism, and Islam, and eventually became a global standard that has resisted all reform attempts.
Does the calendar ever repeat exactly?
Yes. The Gregorian calendar repeats exactly every 400 years because 400 years contain exactly 146,097 days, which is an exact multiple of 7 (20,871 weeks). Within a century, non-leap years often share identical calendars with years 6, 11, or 28 years apart. Two years have the same calendar if they start on the same day of the week and share the same leap year status. For example, 2026 and 2037 have identical calendars.
How many days are in each quarter of the year?
Quarter 1 (January through March) has 90 days in a common year and 91 days in a leap year. Quarter 2 (April through June) always has 91 days. Quarter 3 (July through September) always has 92 days. Quarter 4 (October through December) always has 92 days. The total is 365 or 366 days. These counts are useful for financial reporting, which often operates on quarterly cycles.
Related Calculators
- Age Calculator – Calculate exact age from a birth date.
- Date Difference Calculator – Find days, weeks, and months between dates.
- Days Until Calculator – Count down to any future date.
- Timestamp Calculator – Convert Unix timestamps to dates and back.