28

This question is based on the observations of AdamV in his answer on How do I get the day name into a cell in Excel?

When A1 has the value 2009-08-01, then:

  • =WEEKDAY(A1) will obtain 7
  • =TEXT(7, "dddd") will obtain Saturday
  • =TEXT(7,"dddd, yyyy-mm-dd") will obtain Saturday, 1900-01-07
  • =TEXT(1,"dddd, yyyy-mm-dd") will obtain Sunday, 1900-01-01
  • =TEXT("1900-01-01","dddd, yyyy-mm-dd") will also obtain Sunday, 1900-01-01

The last two are wrong: the 1st of January 1900 is actually a Monday.
Various sources seem to confirm that:

What am I missing? Why is Excel doing this wrong?

1
  • 1
    Thanks to this question I have slightly reworded my previous answer to make it clear that 1/1/1900 is not a Sunday, but Excel thinks it is. The inaccuracy does not change the substance of that previous answer which is that using a weekday number as a basis to produce text formatted to look like a date is flawed and unnecessary.
    – AdamV
    Oct 2, 2012 at 11:10

3 Answers 3

42

As described in Microsoft KB 214058:

Days of the week before March 1, 1900 are incorrect in Excel

MORE INFORMATION

When the date system in Microsoft Excel was originally created, it was designed to be fully compatible with date systems used by other spreadsheet programs.

However, in this date system, the year 1900 is incorrectly interpreted as a leap year. Because there is no February 29 ("leap day") in the year 1900, the day of the week for any date before March 1, 1900 (the day after the "leap day"), is not computed correctly.

The "other spreadsheet programs" refer to Lotus 1-2-3, which was quite popular back then, and incorrectly assumed that year 1900 was a leap year. This is explained in even more detail in KB 214326:

Excel 2000 incorrectly assumes that the year 1900 is a leap year

MORE INFORMATION

When Lotus 1-2-3 was first released, the program assumed that the year 1900 was a leap year, even though it actually was not a leap year. This made it easier for the program to handle leap years and caused no harm to almost all date calculations in Lotus 1-2-3.

When Microsoft Multiplan and Microsoft Excel were released, they also assumed that 1900 was a leap year. This assumption allowed Microsoft Multiplan and Microsoft Excel to use the same serial date system used by Lotus 1-2-3 and provide greater compatibility with Lotus 1-2-3. Treating 1900 as a leap year also made it easier for users to move worksheets from one program to the other.

Although it is technically possible to correct this behavior so that current versions of Microsoft Excel do not assume that 1900 is a leap year, the disadvantages of doing so outweigh the advantages.

If this behavior were to be corrected, many problems would arise, including the following:

  • Almost all dates in current Microsoft Excel worksheets and other documents would be decreased by one day. Correcting this shift would take considerable time and effort, especially in formulas that use dates.
  • Some functions, such as the WEEKDAY function, would return different values; this might cause formulas in worksheets to work incorrectly.
  • Correcting this behavior would break serial date compatibility between Microsoft Excel and other programs that use dates.

If the behavior remains uncorrected, only one problem occurs:

  • The WEEKDAY function returns incorrect values for dates before March 1, 1900. Because most users do not use dates before March 1, 1900, this problem is rare.
4
  • 10
    Here’s a related story from Stack Exchange’s very own Joel Spolsky: joelonsoftware.com/items/2006/06/16.html
    – matt
    Sep 30, 2012 at 21:47
  • 5
    See also. Many programmers incorrectly assume that working with dates/times is easy :) Sep 30, 2012 at 22:18
  • 3
    Historical nitpicK: when you say 1-2-3 was "quite popular" you mean it was once the dominant spreadsheet. Oct 2, 2012 at 17:46
  • Excel also thinks the 0th of January 1900 is a valid date.
    – Mast
    Feb 17, 2021 at 16:38
13

Here is the reason explained by Joel himself: My First BillG Review

Basic uses December 31, 1899 as the epoch instead of January 1, 1900, but for some reason, today's date was the same in Excel as it was in Basic.

Huh?

I went to find an Excel developer who was old enough to remember why. Ed Fries seemed to know the answer.

"Oh," he told me. "Check out February 28th, 1900."

"It's 59," I said.

"Now try March 1st."

"It's 61!"

"What happened to 60?" Ed asked.

"February 29th. 1900 was a leap year! It's divisible by 4!"

"Good guess, but no cigar," Ed said, and left me wondering for a while.

Oops. I did some research. Years that are divisible by 100 are not leap years, unless they're also divisible by 400.

1900 wasn't a leap year.

"It's a bug in Excel!" I exclaimed.

"Well, not really," said Ed. "We had to do it that way because we need to be able to import Lotus 123 worksheets."

"So, it's a bug in Lotus 123?"

"Yeah, but probably an intentional one. Lotus had to fit in 640K. That's not a lot of memory. If you ignore 1900, you can figure out if a given year is a leap year just by looking to see if the rightmost two bits are zero. That's really fast and easy. The Lotus guys probably figured it didn't matter to be wrong for those two months way in the past.

1
  • 1
    @JeroenWiertPluimers: Actually my answer with this link was deleted by moderator and I decided to expand my answer.
    – Giorgi
    Oct 1, 2012 at 18:18
2

One solution to this is to add 400 years to the year, to work out the weekday as in the following formula:

=WEEKDAY(DATE(A4+400,B4,C4),1)

So the following variables

A4 = 1834
B4 = 12
C4 = 14

would return 1 (Sunday), which is the same as for 14 December 2234.
This stops working for dates before 1753, the year after the change to the Gregorian calendar.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .