3 ms·
I discovered this one, recently: > Excel stores dates as sequential serial numbers so that they can be used in calculations. By default, January 1, 1900 is ser
by deathanatos 10y ago
I discovered this one, recently:
> Excel stores dates as sequential serial numbers so that they can be used in calculations. By default, January 1, 1900 is serial number 1, and January 1, 2008 is serial number 39448 because it is 39,447 days after January 1, 1900.
That's from the Microsoft's documentation of Excel[1]. Note this part: "because [Jan 1, 2008] is 39,447 days after January 1, 1900"
In [3]: (datetime.datetime(2008, 1, 1) - datetime.datetime(1900, 1, 1)).days
Out[3]: 39446
Off by one, Microsoft. And yes, Excel does the same thing — i.e., the docs match the product.
If you're wondering why, it's b/c Excel incorrectly thinks that 1900 is a leap year. (Also, this is why a lot of Window's clocks track time since 1901, as it makes leap year calculations simpler… for now.)
[1]: https://support.office.com/en-us/article/DATEVALUE-function-df8b07d4-7761-4a93-bc33-b7471bbff252 https://support.office.com/en-us/article/DATEVALUE-function-...
- ufmace 10y agoI recall reading somewhere on Joel on Software that I can't find at the moment that Microsoft did this deliberately to duplicate a bug in Lotus 1-2-3, because they needed perfect compatibility with formulas and dates with 1-2-3 to get people to switch over. And Lotus 1-2-3 reportedly had this bug because, at the time it was written, the code to account for that case correctly legitimately took up too much space and was dropped, with Lotus figuring that not too many people would notice. And of course, Microsoft can't change it now, or else they'll potentially break a ton of people's spreadsheets that already work around it.